Astro
Every component also comes as an Astro component, with the same markup, CSS and script as the HTML version.
Add components
Add them with the CLI
Terminalnpx designme add live-answer status-pill --astroThey land in
src/components/designme, orcomponents/designmewhen there is nosrcfolder. The shared core,core/designme.cssandcore/core.js, is added once. Without--astro, the CLI says so when it finds anastro.configfile in the folder you run it from.Your project - src/components/designme/
- core/
- designme.css
- core.js
- live-answer/
- LiveAnswer.astro
- live-answer.css
- live-answer.js
- status-pill/
- StatusPill.astro
- status-pill.css
- status-pill.js
- core/
- src/components/designme/
Use them in a page
Astro--- import LiveAnswer from '../components/designme/live-answer/LiveAnswer.astro'; import StatusPill from '../components/designme/status-pill/StatusPill.astro'; --- <LiveAnswer /> <StatusPill data-style="soft" class="my-pill" />The CLI prints the import line for each component. It uses your
@/alias when yourtsconfig.jsonhas one, and a path fromsrc/pageswhen it doesn't.
The shadcn CLI can add them too, from https://designme.dev/r/shadcn/astro/<name>.json. See Installation.
How they work
Markup
Each
.astrofile holds the component's markup exactly as the HTML version has it, inside<Fragment is:raw>, so Astro leaves it as it is. Its root element is the same<div data-c>the HTML version uses.Styles
The component imports
core/designme.cssand its own.cssin its frontmatter. Astro bundles each stylesheet once per page.Script
Its
<script>imports its.js, which is the HTML version's script with one line added: it imports the helpers it uses fromcore/core.js, the shared core as an ES module. Astro bundles each script once per page, however many times the component appears.Mounting
The core starts each component when it scrolls into view and plays its demo, as on designme.dev. A click, a key or typing inside it stops the demo for good. With Astro's client router (
<ClientRouter />), the core also starts the components on each page it brings in, and stops the ones it takes away.
Props
Each component has a typed Props interface: every attribute of a <div> (Astro's HTMLAttributes<'div'>), plus data-style. They all go on the component's root element.
| Prop | What it does |
|---|---|
data-style="soft", data-style="studio" | Draws the component in the Soft or the Studio style. Leave it out for Blueprint, or for the style set on <html> |
class | Added to the root element's own classes |
style, id, aria-* and the rest | Set on the root element as they are |
data-style takes "soft" or "studio": Blueprint is what the components draw without it. A component can be Soft or Studio on a Blueprint page, but not Blueprint on a Soft or Studio one. See Theming.
Your own data
The Astro components play the demos from designme.dev. To show your own data, change the component's .js (and its markup in the .astro file), as you would with the HTML version.
To drive a component from your own state with props, use the React version as an island: npx astro add react, then npx designme add <name> --react, and hydrate it with a directive such as client:visible.
Style, theme and fonts
data-style="soft"on<html>makes every component Soft, anddata-style="studio"Studio; on one component, just that one.data-theme="dark"ordata-theme="light"on<html>fixes the theme. Without it, the components follow the device.- Load Inter and JetBrains Mono for the full look. Without them, the components fall back to the system font.
- The components use plain class names, as the HTML version does, and CSS variables that start with
--dm-, so they never meet your page's own. For a shadcn/ui or Tailwind v4 theme, add the theme bridge:npx designme add --astro --theme-bridge. See Installation.
This page as Markdown: astro.md