Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Frame for Astro

Frame components for a subtle raised surface.

FramePanel adds a subtle raised surface to a single element. Frame groups several panels (and optional header or footer) inside one muted shell.

Section header
Files and notes for the next content review

Section title

Section description

Footer

Installation

bunx --bun shadcn@latest add @gnostic/frame
npx shadcn@latest add @gnostic/frame
pnpm dlx shadcn@latest add @gnostic/frame

Complete the Installation guide first. Then copy the component files below.

No extra packages are required.

Copy the files

src/components/ui/frame/frame-description.astro
---
/**
 * Supporting text under a frame title.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="frame-panel-description"
  class={cn("text-muted-foreground text-sm", className)}
  {...props}
>
  <slot />
</div>
src/components/ui/frame/frame-footer.astro
---
/**
 * Footer band for actions or secondary text.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"footer">

const { class: className, ...props } = Astro.props
---

<footer
  data-slot="frame-panel-footer"
  class={cn("px-5 py-4", className)}
  {...props}
>
  <slot />
</footer>
src/components/ui/frame/frame-header.astro
---
/**
 * Header band for a frame title and description.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"header">

const { class: className, ...props } = Astro.props
---

<header
  data-slot="frame-panel-header"
  class={cn("flex flex-col px-5 py-4", className)}
  {...props}
>
  <slot />
</header>
src/components/ui/frame/frame-panel.astro
---
/**
 * Raised surface inside a frame. Stacked panels keep a small gap.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="frame-panel"
  class={cn(
    "relative rounded-xl border bg-background bg-clip-padding p-5 shadow-xs/5 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
    className,
  )}
  {...props}
>
  <slot />
</div>
src/components/ui/frame/frame-title.astro
---
/**
 * Title text for a frame header.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="frame-panel-title"
  class={cn("text-sm font-semibold", className)}
  {...props}
>
  <slot />
</div>
src/components/ui/frame/frame.astro
---
/**
 * Muted shell that groups a header, panels, and a footer.
 * Panel spacing follows the Coss UI frame styles.
 */
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div
  data-slot="frame"
  class={cn(
    "relative flex flex-col rounded-2xl bg-muted/72 p-1",
    "*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-1",
    className,
  )}
  {...props}
>
  <slot />
</div>
src/components/ui/frame/index.ts
export { default as Frame } from './frame.astro'
export { default as FrameDescription } from './frame-description.astro'
export { default as FrameFooter } from './frame-footer.astro'
export { default as FrameHeader } from './frame-header.astro'
export { default as FramePanel } from './frame-panel.astro'
export { default as FrameTitle } from './frame-title.astro'

Usage

---
import {
    Frame,
    FrameDescription,
    FrameFooter,
    FrameHeader,
    FramePanel,
    FrameTitle,
} from "@/components/ui/frame"
---

<Frame>
  <FrameHeader>
    <FrameTitle>Title</FrameTitle>
    <FrameDescription>Description</FrameDescription>
  </FrameHeader>
  <FramePanel>Content</FramePanel>
  <FrameFooter>Footer</FrameFooter>
</Frame>

Composition

Frame
├── FrameHeader
│   ├── FrameTitle
│   └── FrameDescription
├── FramePanel
└── FrameFooter

Examples

Framed icon

Use FramePanel around an icon to make it stand out.

Winter landscape
Winter is Coming
Prepare for solitude in the frozen landscape.

An alien world awaits your arrival. What was once uninhabitable is now home. You are the first of your species to arrive on this planet. Make the most of it.

See the card examples for CardFrame, which clips a card into a framed shell.

When to use Frame

Use FramePanel alone when one raised surface is enough, as in the framed icon example. Use Frame when multiple panels should sit together in one outer surface.

Keyboard and behavior

Frame supplies layout, not selection or disclosure behavior. Use semantic headings and actual buttons inside the parts. The page still owns heading levels and landmarks.

Theme and layout

With Frame, the outer muted shell and inner panels share border and radius tokens. A lone FramePanel uses the panel tokens only. Check panel edges and spacing when content includes a table or a card with its own border. Avoid stacking unnecessary surfaces.