Select | jaspr_daisyui_components
jaspr_daisyui_components
pub.dev ↗

Select

Select is used to pick a value from a list of options.

Class name Type Description
select Component For <select> element
select-ghost Style ghost style
select-neutral Color neutral color
select-primary Color primary color
select-secondary Color secondary color
select-accent Color accent color
select-info Color info color
select-success Color success color
select-warning Color warning color
select-error Color error color
select-xs Size Extra small size
select-sm Size Small size
select-md Size Medium size
select-lg Size Large size
select-xl Size Extra large size

Select

<select class="select">
  <option disabled="" selected="">Pick a color</option>
  <option>Crimson</option>
  <option>Amber</option>
  <option>Velvet</option>
</select>
Select(
  [
    option([Component.text('Pick a color')], selected: true, disabled: true),
    option([Component.text('Crimson')]),
    option([Component.text('Amber')]),
    option([Component.text('Velvet')]),
  ],
);

Ghost (no background)

<select class="select select-ghost">
  <option disabled="" selected="">Pick a font</option>
  <option>Inter</option>
  <option>Poppins</option>
  <option>Raleway</option>
</select>
Select(
  [
    option([Component.text('Pick a font')], selected: true, disabled: true),
    option([Component.text('Inter')]),
    option([Component.text('Poppins')]),
    option([Component.text('Raleway')]),
  ],
  style: [SelectStyle.ghost],
);

With fieldset and labels

Browsers Optional
<fieldset class="fieldset">
  <legend class="fieldset-legend">Browsers</legend>
  <select class="select">
    <option disabled="" selected="">Pick a browser</option>
    <option>Chrome</option>
    <option>FireFox</option>
    <option>Safari</option>
  </select>
  <span class="label">Optional</span>
</fieldset>
Fieldset(
  [
    FieldsetLegend([Component.text('Browsers')]),
    Select(
      [
        option([Component.text('Pick a browser')], selected: true, disabled: true),
        option([Component.text('Chrome')]),
        option([Component.text('FireFox')]),
        option([Component.text('Safari')]),
      ],
    ),
    span([Component.text('Optional')], classes: 'label'),
  ],
);

Primary color

<select class="select select-primary">
  <option disabled="" selected="">Pick a text editor</option>
  <option>VScode</option>
  <option>VScode fork</option>
  <option>Another VScode fork</option>
</select>
Select(
  [
    option([Component.text('Pick a text editor')], selected: true, disabled: true),
    option([Component.text('VScode')]),
    option([Component.text('VScode fork')]),
    option([Component.text('Another VScode fork')]),
  ],
  color: SelectColor.primary,
);

Secondary color

<select class="select select-secondary">
  <option disabled="" selected="">Pick a language</option>
  <option>Zig</option>
  <option>Go</option>
  <option>Rust</option>
</select>
Select(
  [
    option([Component.text('Pick a language')], selected: true, disabled: true),
    option([Component.text('Zig')]),
    option([Component.text('Go')]),
    option([Component.text('Rust')]),
  ],
  color: SelectColor.secondary,
);

Accent color

<select class="select select-accent">
  <option selected="" disabled="">Color scheme</option>
  <option>Light mode</option>
  <option>Dark mode</option>
  <option>System</option>
</select>
Select(
  [
    option([Component.text('Color scheme')], selected: true, disabled: true),
    option([Component.text('Light mode')]),
    option([Component.text('Dark mode')]),
    option([Component.text('System')]),
  ],
  color: SelectColor.accent,
);

Neutral color

<select class="select select-neutral">
  <option disabled="" selected="">Server location</option>
  <option>North America</option>
  <option>EU west</option>
  <option>South East Asia</option>
</select>
Select(
  [
    option([Component.text('Server location')], selected: true, disabled: true),
    option([Component.text('North America')]),
    option([Component.text('EU west')]),
    option([Component.text('South East Asia')]),
  ],
  color: SelectColor.neutral,
);

Info color

<select class="select select-info">
  <option disabled="" selected="">Pick a Framework</option>
  <option>React</option>
  <option>Vue</option>
  <option>Angular</option>
</select>
Select(
  [
    option([Component.text('Pick a Framework')], selected: true, disabled: true),
    option([Component.text('React')]),
    option([Component.text('Vue')]),
    option([Component.text('Angular')]),
  ],
  color: SelectColor.info,
);

Success color

<select class="select select-success">
  <option disabled="" selected="">Pick a Runtime</option>
  <option>npm</option>
  <option>Bun</option>
  <option>yarn</option>
</select>
Select(
  [
    option([Component.text('Pick a Runtime')], selected: true, disabled: true),
    option([Component.text('npm')]),
    option([Component.text('Bun')]),
    option([Component.text('yarn')]),
  ],
  color: SelectColor.success,
);

Warning color

<select class="select select-warning">
  <option disabled="" selected="">Pick an OS</option>
  <option>Windows</option>
  <option>MacOS</option>
  <option>Linux</option>
</select>
Select(
  [
    option([Component.text('Pick an OS')], selected: true, disabled: true),
    option([Component.text('Windows')]),
    option([Component.text('MacOS')]),
    option([Component.text('Linux')]),
  ],
  color: SelectColor.warning,
);

Error color

<select class="select select-error">
  <option disabled="" selected="">Pick an AI Model</option>
  <option>GPT-4</option>
  <option>Claude</option>
  <option>Llama</option>
</select>
Select(
  [
    option([Component.text('Pick an AI Model')], selected: true, disabled: true),
    option([Component.text('GPT-4')]),
    option([Component.text('Claude')]),
    option([Component.text('Llama')]),
  ],
  color: SelectColor.error,
);

Sizes

<select class="select select-xs">
  <option disabled="" selected="">Xsmall</option>
  <option>Xsmall Apple</option>
  <option>Xsmall Orange</option>
  <option>Xsmall Tomato</option>
</select>
<select class="select select-sm">
  <option disabled="" selected="">Small</option>
  <option>Small Apple</option>
  <option>Small Orange</option>
  <option>Small Tomato</option>
</select>
<select class="select select-md">
  <option disabled="" selected="">Medium</option>
  <option>Medium Apple</option>
  <option>Medium Orange</option>
  <option>Medium Tomato</option>
</select>
<select class="select select-lg">
  <option disabled="" selected="">Large</option>
  <option>Large Apple</option>
  <option>Large Orange</option>
  <option>Large Tomato</option>
</select>
<select class="select select-xl">
  <option disabled="" selected="">Xlarge</option>
  <option>Xlarge Apple</option>
  <option>Xlarge Orange</option>
  <option>Xlarge Tomato</option>
</select>
Component.fragment([
  Select(
    [
      option([Component.text('Xsmall')], selected: true, disabled: true),
      option([Component.text('Xsmall Apple')]),
      option([Component.text('Xsmall Orange')]),
      option([Component.text('Xsmall Tomato')]),
    ],
    size: SelectSize.xs,
  ),
  Select(
    [
      option([Component.text('Small')], selected: true, disabled: true),
      option([Component.text('Small Apple')]),
      option([Component.text('Small Orange')]),
      option([Component.text('Small Tomato')]),
    ],
    size: SelectSize.sm,
  ),
  Select(
    [
      option([Component.text('Medium')], selected: true, disabled: true),
      option([Component.text('Medium Apple')]),
      option([Component.text('Medium Orange')]),
      option([Component.text('Medium Tomato')]),
    ],
    size: SelectSize.md,
  ),
  Select(
    [
      option([Component.text('Large')], selected: true, disabled: true),
      option([Component.text('Large Apple')]),
      option([Component.text('Large Orange')]),
      option([Component.text('Large Tomato')]),
    ],
    size: SelectSize.lg,
  ),
  Select(
    [
      option([Component.text('Xlarge')], selected: true, disabled: true),
      option([Component.text('Xlarge Apple')]),
      option([Component.text('Xlarge Orange')]),
      option([Component.text('Xlarge Tomato')]),
    ],
    size: SelectSize.xl,
  ),
]);

Disabled

<select class="select" disabled="">
  <option>You can't touch this</option>
</select>
Select([option([Component.text('You can\'t touch this')])], disabled: true);

Using OS native style for the options dropdown

<select class="select appearance-none">
  <option disabled="" selected="">Pick a color</option>
  <option>Crimson</option>
  <option>Amber</option>
  <option>Velvet</option>
</select>
Select(
  [
    option([Component.text('Pick a color')], selected: true, disabled: true),
    option([Component.text('Crimson')]),
    option([Component.text('Amber')]),
    option([Component.text('Velvet')]),
  ],
  classes: 'appearance-none',
);

Select with custom dropdown height

<select class="select [&amp;::picker(select)]:max-h-26">
  <option disabled="" selected="">Pick a color</option>
  <option>Crimson</option>
  <option>Amber</option>
  <option>Velvet</option>
</select>
Select(
  [
    option([Component.text('Pick a color')], selected: true, disabled: true),
    option([Component.text('Crimson')]),
    option([Component.text('Amber')]),
    option([Component.text('Velvet')]),
  ],
  classes: '[&::picker(select)]:max-h-26',
);