Skip to content
Viewership Inquire
Astro UI

Segmented Control.

Equal-width segments with a sliding thumb, as a radio group.

InputsAtomNo dependencies Beautiful UI, MIT

.md
AI citations

412cites 27 new across 9 topics

Engine

Install

  1. Import the foundation once

    foundation.css holds the tokens every component reads.

    Layout.astro
    ---
    // src/layouts/Layout.astro
    import "../styles/foundation.css";
    ---
  2. Copy SegmentedControl.astro

    Paste into src/components/viewership/segmented-control/

  3. Use it

    Page.astro
    ---
    import SegmentedControl from "../components/viewership/segmented-control/SegmentedControl.astro";
    ---
    
    <SegmentedControl />

Props 4

PropTypeDefaultDescription
options (string | { value: string; label: string })[] · The segments, in order.
value string · Selected value (default: first).
label string · Accessible group name, or use aria-labelledby.
name string · Form field name. Adds a hidden input.

Events

EventDetailWhen
vs-change CustomEvent<{ value: string; index: number }> Fires on selection. Root mirrors data-value.

Source 1 file

Ported from Beautiful UI, MIT. Notices.