Buttons & actions / Segmented buttons
Composer Pill Controls
Small outlined pills above the composer: model dropdown, a Default/Max segmented toggle with a filled active half, and a shield pool dropdown.
Rebuilt from silico.ai/features in the Moonlit Atelier style.
npx shadcn@latest add https://justyoink.it/r/moonlit-atelier/blocks/pill-toggle-bar.json
Looks exactly like silico.ai: brings its fonts and colours, namespaced so your own theme stays untouched.
npx shadcn@latest add https://justyoink.it/r/moonlit-atelier/mine/pill-toggle-bar.json
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
Usage
Props: models, segments, pools (string arrays; first item is the default label) and placeholder. Renders standalone; dropdowns open upward and chevrons rotate, and the active segment fills with the raised surface.
components/pill-toggle-bar.tsx
import { useState } from "react"; type Props = { models?: string[]; segments?: string[]; pools?: string[]; placeholder?: string; }; function Chevron({ open }: { open: boolean }) { return ( <svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" className={`transition-transform duration-ui-hover ease-ui-hover ${open ? "rotate-180" : ""}`}> <path d="M3 4.5 6 7.5 9 4.5" /> </svg> ); } function Dropdown({ label, options, icon, ariaLabel }: { label: string; options: string[]; icon?: boolean; ariaLabel: string }) { const [open, setOpen] = useState(false); const [value, setValue] = useState(label); return ( <div className="relative"> <button type="button" aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={open} onClick={() => setOpen(!open)} className="inline-flex h-8 items-center gap-1.5 rounded-pill border border-hairline px-3 font-sans text-caption text-muted transition-colors duration-ui-hover ease-ui-hover hover:border-hairline-strong hover:text-primary focus-visible:outline focus-visible:outline-1 focus-visible:outline-hairline-strong"> {icon && ( <svg width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinejoin="round" aria-hidden="true"> <path d="M8 1.5 13 3.5v4c0 3-2.2 5.3-5 6.5-2.8-1.2-5-3.5-5-6.5v-4z" /> </svg> )} {value} <Chevron open={open} /> </button> {open && ( <ul role="listbox" className="absolute bottom-full left-0 z-10 mb-2 min-w-36 animate-menu-pop rounded-lg border border-hairline bg-surface-raised p-1 shadow-float-window"> {options.map((o) => ( <li key={o}> <button type="button" role="option" aria-selected={o === value} onClick={() => { setValue(o); setOpen(false); }} className="w-full rounded-md px-3 py-1.5 text-left font-sans text-caption text-secondary hover:bg-surface-high hover:text-primary"> {o} </button> </li> ))} </ul> )} </div> ); } export default function ComposerPillControls({ models = ["Auto", "Fast", "Balanced", "Deep"], segments = ["Default", "Max"], pools = ["No pool", "Latest models", "Team pool"], placeholder = "Message the assistant…", }: Props) { const [active, setActive] = useState(0); return ( <div className="w-full max-w-3xl bg-canvas-warm p-4 font-sans"> <div className="mb-3 flex flex-wrap items-center gap-2"> <Dropdown label={models[0]} options={models} ariaLabel="Model" /> <div role="group" aria-label="Effort" className="inline-flex h-8 overflow-hidden rounded-pill border border-hairline"> {segments.map((s, i) => ( <button key={s} type="button" aria-pressed={active === i} onClick={() => setActive(i)} className={`px-3 text-caption transition-colors duration-ui-hover ease-ui-hover focus-visible:outline focus-visible:outline-1 focus-visible:outline-hairline-strong ${active === i ? "bg-surface-raised text-primary font-medium" : "text-muted hover:text-primary"}`}> {s} </button> ))} </div> <Dropdown label={pools[0]} options={pools} icon ariaLabel="Pool" /> </div> <div className="rounded-xl border border-hairline bg-surface-high p-4"> <p className="text-body text-muted">{placeholder}</p> <div className="mt-6 flex items-center justify-between"> <button type="button" aria-label="Add attachment" className="text-muted hover:text-primary"> <svg width="16" height="16" viewBox="0 0 16 16" stroke="currentColor" strokeWidth="1.2" aria-hidden="true"><path d="M8 3v10M3 8h10" /></svg> </button> <button type="button" aria-label="Send" className="flex h-9 w-9 items-center justify-center rounded-pill bg-paper text-canvas transition-opacity duration-ui-hover ease-ui-hover hover:opacity-85"> <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" aria-hidden="true"><path d="M8 13V3M3.5 7.5 8 3l4.5 4.5" /></svg> </button> </div> </div> </div> ); }import { useState } from "react"; type Props = { models?: string[]; segments?: string[]; pools?: string[]; placeholder?: string; }; function Chevron({ open }: { open: boolean }) { return ( <svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" className={`transition-transform duration-moonlit-ui-hover ease-moonlit-ui-hover ${open ? "rotate-180" : ""}`}> <path d="M3 4.5 6 7.5 9 4.5" /> </svg> ); } function Dropdown({ label, options, icon, ariaLabel }: { label: string; options: string[]; icon?: boolean; ariaLabel: string }) { const [open, setOpen] = useState(false); const [value, setValue] = useState(label); return ( <div className="relative"> <button type="button" aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={open} onClick={() => setOpen(!open)} className="inline-flex h-8 items-center gap-1.5 rounded-full border border-border px-3 font-sans text-moonlit-caption text-muted-foreground transition-colors duration-moonlit-ui-hover ease-moonlit-ui-hover hover:border-border hover:text-foreground focus-visible:outline focus-visible:outline-1 focus-visible:outline-border"> {icon && ( <svg width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinejoin="round" aria-hidden="true"> <path d="M8 1.5 13 3.5v4c0 3-2.2 5.3-5 6.5-2.8-1.2-5-3.5-5-6.5v-4z" /> </svg> )} {value} <Chevron open={open} /> </button> {open && ( <ul role="listbox" className="absolute bottom-full left-0 z-10 mb-2 min-w-36 animate-moonlit-menu-pop rounded-xl border border-border bg-muted p-1 shadow-moonlit-float-window"> {options.map((o) => ( <li key={o}> <button type="button" role="option" aria-selected={o === value} onClick={() => { setValue(o); setOpen(false); }} className="w-full rounded-md px-3 py-1.5 text-left font-sans text-moonlit-caption text-muted-foreground hover:bg-muted hover:text-foreground"> {o} </button> </li> ))} </ul> )} </div> ); } export default function ComposerPillControls({ models = ["Auto", "Fast", "Balanced", "Deep"], segments = ["Default", "Max"], pools = ["No pool", "Latest models", "Team pool"], placeholder = "Message the assistant…", }: Props) { const [active, setActive] = useState(0); return ( <div className="w-full max-w-3xl bg-card p-4 font-sans"> <div className="mb-3 flex flex-wrap items-center gap-2"> <Dropdown label={models[0]} options={models} ariaLabel="Model" /> <div role="group" aria-label="Effort" className="inline-flex h-8 overflow-hidden rounded-full border border-border"> {segments.map((s, i) => ( <button key={s} type="button" aria-pressed={active === i} onClick={() => setActive(i)} className={`px-3 text-moonlit-caption transition-colors duration-moonlit-ui-hover ease-moonlit-ui-hover focus-visible:outline focus-visible:outline-1 focus-visible:outline-border ${active === i ? "bg-muted text-foreground font-medium" : "text-muted-foreground hover:text-foreground"}`}> {s} </button> ))} </div> <Dropdown label={pools[0]} options={pools} icon ariaLabel="Pool" /> </div> <div className="rounded-2xl border border-border bg-muted p-4"> <p className="text-moonlit-body text-muted-foreground">{placeholder}</p> <div className="mt-6 flex items-center justify-between"> <button type="button" aria-label="Add attachment" className="text-muted-foreground hover:text-foreground"> <svg width="16" height="16" viewBox="0 0 16 16" stroke="currentColor" strokeWidth="1.2" aria-hidden="true"><path d="M8 3v10M3 8h10" /></svg> </button> <button type="button" aria-label="Send" className="flex h-9 w-9 items-center justify-center rounded-full bg-primary text-primary-foreground transition-opacity duration-moonlit-ui-hover ease-moonlit-ui-hover hover:opacity-85"> <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" aria-hidden="true"><path d="M8 13V3M3.5 7.5 8 3l4.5 4.5" /></svg> </button> </div> </div> </div> ); }
Quality checks
Automated, in a real browser · 4d ago- Accessible: not passedElements must meet minimum color contrast ratio thresholds (4 elements)
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: passedStill readable when installed in your theme and switched to dark mode.
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: doesn't applyDoesn't animate, so there's nothing to check.