Data displayFeatureItem
Searchastronomic.dev# FeatureItem
For one feature in a Features list: its title, a short text, and an icon or image. The feature recipes use it for you.
Static: no JavaScript.
## Usage
```astro
import FeatureItem from "@astronomic-dev/ui/components/FeatureItem.astro";
```
## Examples
### Plain and as a card
One feature in a Features list. The feature recipes build their items from it, so you only need it for your own layout.
```astro
---
import FeatureItem from "@astronomic-dev/ui/components/FeatureItem.astro";
import Features from "@astronomic-dev/ui/components/Features.astro";
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
const heading = "How we work";
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl">
<Features heading={heading} listClass="@3xl/features:grid-cols-2">
<FeatureItem title="Plain items" text="A title and a short text, with an optional lead above the title." headingTag={tag}>
<span slot="lead" class="text-small font-semibold text-accent">01</span>
</FeatureItem>
<FeatureItem card title="As a card" text="With card, the item is a Card, with an optional image on top." headingTag={tag} />
</Features>
</div>
```
## Props
### FeatureItem
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | None | Required. The title, in the heading role in display type. |
| `text` | `string` | None | Required. A short text under the title, in the body role, muted. |
| `headingTag` | `"h2" \| "h3" \| "h4" \| "h5"` | None | Required. The title element. Pass childHeadingTag({ heading, headingTag }) from lib/heading.ts, one level under the section heading. |
| `card` | `boolean` | `false` | Draws the item as a Card that fills the row's height. |
| `image` | `MediaImage` | None | An image at the top of the card (Card's `image`). Only with `card`. |
| `titleClass` | `string` | None | For recipes. Classes for the title, after its own. |
| `textClass` | `string` | None | For recipes. Classes for the text block (the title and the text). |
| `mediaClass` | `string` | None | For recipes. Classes for the media block after the text. Not used with `card`. |
| `class` | `string` | None | More classes for the <li>, merged with cn(), so yours win on conflicts. |
| Slot | Description |
| --- | --- |
| `lead` | Above the title, such as an icon. An empty slot leaves no block. |
| `media` | After the text, such as a row's image. Not used with card. An empty slot leaves no block. |
Any other attribute goes on the <li>.
## Accessibility
- Renders one <li>: put it in a Features list.
- The title is the heading level you pass. Use childHeadingTag so it sits one level under the section heading.
- An icon in the lead slot is decoration: give it aria-hidden="true".
FeatureItem
FreeFor one feature in a Features list: its title, a short text, and an icon or image. The feature recipes use it for you.
- File
- FeatureItem.astro
- Group
- Data display
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Plain and as a card
One feature in a Features list. The feature recipes build their items from it, so you only need it for your own layout.
How we work
- 01
Plain items
A title and a short text, with an optional lead above the title.
As a card
With card, the item is a Card, with an optional image on top.
Force statemain.astro
examples/featureitem/main.astro
---
import FeatureItem from "@astronomic-dev/ui/components/FeatureItem.astro";
import Features from "@astronomic-dev/ui/components/Features.astro";
import { childHeadingTag } from "@astronomic-dev/ui/lib/heading.ts";
const heading = "How we work";
const tag = childHeadingTag({ heading });
---
<div class="mx-auto max-w-6xl">
<Features heading={heading} listClass="@3xl/features:grid-cols-2">
<FeatureItem title="Plain items" text="A title and a short text, with an optional lead above the title." headingTag={tag}>
<span slot="lead" class="text-small font-semibold text-accent">01</span>
</FeatureItem>
<FeatureItem card title="As a card" text="With card, the item is a Card, with an optional image on top." headingTag={tag} />
</Features>
</div>Minimal · Light