Select component allows users to choose one option from a list of options. Consider using the Select component when you have 6 or more options.
import { Select } from "@kesko/components";
export default () => (
<Select label="Store" name="store" placeholder="Choose a store">
<option value="sello">K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
<option value="toolo">K-Market Töölö</option>
</Select>
);<k-select>
<label class="k-label" for="store">Store</label>
<div class="k-field">
<select id="store" name="store">
<option value="">Choose a store</option>
<option value="sello">K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
<option value="toolo">K-Market Töölö</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>import { Select } from "@kesko/components";
export default () => (
<Select
label="Receipt"
name="receipt"
defaultValue="email"
description="Where we send the receipt after each purchase."
>
<option value="email">By email</option>
<option value="app">In the K-Ruoka app</option>
<option value="paper">Printed at the checkout</option>
</Select>
);<k-select>
<label class="k-label" for="receipt">Receipt</label>
<div class="k-field">
<select id="receipt" name="receipt" aria-describedby="receipt-description">
<option value="email" selected>By email</option>
<option value="app">In the K-Ruoka app</option>
<option value="paper">Printed at the checkout</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
<p class="k-field-description" id="receipt-description">Where we send the receipt after each purchase.</p>
</k-select>import { Select } from "@kesko/components";
const subtle = {
"--k-label-text": "var(--k-color-text-dim)",
"--k-label-weight": "var(--k-font-weight-medium)",
"--k-label-required": "var(--k-color-status-error)",
};
export default () => (
<Select label="Custom label" name="custom" placeholder="Choose an option" required style={subtle}>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</Select>
);<k-select
style="
--k-label-text: var(--k-color-text-dim);
--k-label-weight: var(--k-font-weight-medium);
--k-label-required: var(--k-color-status-error);"
>
<label class="k-label" for="custom">Custom label<span class="k-label-required" aria-hidden="true">*</span></label>
<div class="k-field">
<select id="custom" name="custom" required>
<option value="">Choose an option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>import { Select, Stack } from "@kesko/components";
export default () => (
<Stack direction="row">
<Select label="Quantity" name="quantity" defaultValue="1" style={{ "--k-select-inline-size": "6rem" }}>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</Select>
<Select label="Unit" name="unit" defaultValue="kg" style={{ "--k-select-inline-size": "8rem" }}>
<option value="kg">kg</option>
<option value="g">g</option>
<option value="pcs">pcs</option>
</Select>
<Select label="Store" name="store" placeholder="Choose a store" style={{ "--k-select-inline-size": "16rem" }}>
<option value="sello">K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
</Select>
</Stack>
);<k-stack direction="row">
<k-select style="--k-select-inline-size: 6rem;">
<label class="k-label" for="quantity">Quantity</label>
<div class="k-field">
<select id="quantity" name="quantity">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
<k-select style="--k-select-inline-size: 8rem;">
<label class="k-label" for="unit">Unit</label>
<div class="k-field">
<select id="unit" name="unit">
<option value="kg" selected>kg</option>
<option value="g">g</option>
<option value="pcs">pcs</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
<k-select style="--k-select-inline-size: 16rem;">
<label class="k-label" for="store">Store</label>
<div class="k-field">
<select id="store" name="store">
<option value="">Choose a store</option>
<option value="sello">K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
</k-stack>import { Select } from "@kesko/components";
export default () => (
<Select label="Delivery method" name="delivery" defaultValue="pickup">
<option value="home">Home delivery</option>
<option value="pickup">Pickup from store</option>
<option value="locker">Parcel locker</option>
</Select>
);<k-select>
<label class="k-label" for="delivery">Delivery method</label>
<div class="k-field">
<select id="delivery" name="delivery">
<option value="home">Home delivery</option>
<option value="pickup" selected>Pickup from store</option>
<option value="locker">Parcel locker</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>import { Select, Stack } from "@kesko/components";
export default () => (
<Stack>
<Select label="Store" name="store" defaultValue="sello" disabled>
<option value="sello">K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
</Select>
<Select label="Delivery slot" name="slot" placeholder="Choose a time">
<option value="morning">8–12</option>
<option value="afternoon" disabled>
12–16 (full)
</option>
<option value="evening">16–20</option>
</Select>
</Stack>
);<k-stack>
<k-select>
<label class="k-label" for="store">Store</label>
<div class="k-field">
<select id="store" name="store" disabled>
<option value="sello" selected>K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
<k-select>
<label class="k-label" for="slot">Delivery slot</label>
<div class="k-field">
<select id="slot" name="slot">
<option value="">Choose a time</option>
<option value="morning">8–12</option>
<option value="afternoon" disabled>12–16 (full)</option>
<option value="evening">16–20</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
</k-stack>import { Select } from "@kesko/components";
export default () => (
<Select label="Product" name="product" placeholder="Choose a product">
<optgroup label="Fruit">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
</optgroup>
<optgroup label="Vegetables">
<option value="carrot">Carrot</option>
<option value="cucumber">Cucumber</option>
</optgroup>
</Select>
);<k-select>
<label class="k-label" for="product">Product</label>
<div class="k-field">
<select id="product" name="product">
<option value="">Choose a product</option>
<optgroup label="Fruit">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
</optgroup>
<optgroup label="Vegetables">
<option value="carrot">Carrot</option>
<option value="cucumber">Cucumber</option>
</optgroup>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>import { Select, Stack } from "@kesko/components";
import { IconCalendar, IconLocation } from "@kesko/iconography/react";
export default () => (
<Stack>
<Select label="Pickup store" name="store" placeholder="Choose a store">
<IconLocation slot="start" />
<option value="sello">K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
<option value="toolo">K-Market Töölö</option>
</Select>
<Select label="Delivery day" name="day" defaultValue="tue">
<IconCalendar slot="start" />
<option value="mon">Monday</option>
<option value="tue">Tuesday</option>
<option value="wed">Wednesday</option>
</Select>
</Stack>
);<k-stack>
<k-select>
<label class="k-label" for="store">Pickup store</label>
<div class="k-field">
<svg slot="start" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M12 13c-1.655 0-3-1.345-3-3s1.345-3 3-3 3 1.345 3 3-1.345 3-3 3zm0-4.5a1.501 1.501 0 0 0 0 3 1.501 1.501 0 0 0 0-3z" fill="currentColor" /><path d="M17.985 5.43l-.502.502a.401.401 0 0 0-.046.51c.673 1.023 1.065 2.245 1.065 3.558s-.367 2.48-1.052 3.535l-5.447 8.04-5.44-8.027A6.5 6.5 0 0 1 5.502 10c0-3.585 2.914-6.5 6.5-6.5 1.312 0 2.534.393 3.557 1.065.162.105.372.09.51-.045l.502-.502a.401.401 0 0 0-.057-.615 7.947 7.947 0 0 0-4.513-1.4c-4.412 0-8 3.59-8 8 0 1.544.45 3.054 1.31 4.374l6.068 8.955a.745.745 0 0 0 1.24 0l6.075-8.967A7.989 7.989 0 0 0 19.997 10a7.947 7.947 0 0 0-1.4-4.513.4.4 0 0 0-.615-.057z" fill="currentColor" /></svg>
<select id="store" name="store">
<option value="">Choose a store</option>
<option value="sello">K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
<option value="toolo">K-Market Töölö</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
<k-select>
<label class="k-label" for="day">Delivery day</label>
<div class="k-field">
<svg slot="start" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M22 4.75v14.5c0 .968-.782 1.75-1.75 1.75H3.75C2.782 21 2 20.218 2 19.25V10.4c0-.22.18-.4.4-.4h.7c.22 0 .4.18.4.4v8.85c0 .138.112.25.25.25h16.5a.25.25 0 0 0 .25-.25V4.75a.25.25 0 0 0-.25-.25H17v.6c0 .22-.18.4-.4.4h-.7c-.22 0-.4-.18-.4-.4v-.6h-7v.6c0 .22-.18.4-.4.4h-.7c-.22 0-.4-.18-.4-.4v-.6H3.75a.25.25 0 0 0-.25.25V7h15.35c.22 0 .4.18.4.4v.7c0 .22-.18.4-.4.4H2.75A.749.749 0 0 1 2 7.75v-3C2 3.782 2.782 3 3.75 3H7v-.6c0-.22.18-.4.4-.4h.7c.22 0 .4.18.4.4V3h7v-.6c0-.22.18-.4.4-.4h.7c.22 0 .4.18.4.4V3h3.25c.968 0 1.75.782 1.75 1.75zM11.4 11.5h1.2c.22 0 .4-.18.4-.4v-.7c0-.22-.18-.4-.4-.4h-1.2c-.22 0-.4.18-.4.4v.7c0 .22.18.4.4.4zm5 0h1.2c.22 0 .4-.18.4-.4v-.7c0-.22-.18-.4-.4-.4h-1.2c-.22 0-.4.18-.4.4v.7c0 .22.18.4.4.4zm-10 3h1.2c.22 0 .4-.18.4-.4v-.7c0-.22-.18-.4-.4-.4H6.4c-.22 0-.4.18-.4.4v.7c0 .22.18.4.4.4zm4.6-.4c0 .22.18.4.4.4h1.2c.22 0 .4-.18.4-.4v-.7c0-.22-.18-.4-.4-.4h-1.2c-.22 0-.4.18-.4.4zm5 0c0 .22.18.4.4.4h1.2c.22 0 .4-.18.4-.4v-.7c0-.22-.18-.4-.4-.4h-1.2c-.22 0-.4.18-.4.4zm-10 3c0 .22.18.4.4.4h1.2c.22 0 .4-.18.4-.4v-.7c0-.22-.18-.4-.4-.4H6.4c-.22 0-.4.18-.4.4zm5 0c0 .22.18.4.4.4h1.2c.22 0 .4-.18.4-.4v-.7c0-.22-.18-.4-.4-.4h-1.2c-.22 0-.4.18-.4.4z" fill="currentColor" /></svg>
<select id="day" name="day">
<option value="mon">Monday</option>
<option value="tue" selected>Tuesday</option>
<option value="wed">Wednesday</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
</k-stack>import { Select, Stack } from "@kesko/components";
export default () => (
<Stack>
<Select label="Country" name="country" autoComplete="country" placeholder="Choose a country" required>
<option value="FI">Finland</option>
<option value="SE">Sweden</option>
<option value="NO">Norway</option>
</Select>
<Select label="Language" name="language" placeholder="Choose a language" required hideRequired>
<option value="fi">Suomi</option>
<option value="sv">Svenska</option>
<option value="en">English</option>
</Select>
</Stack>
);<k-stack>
<k-select>
<label class="k-label" for="country">Country<span class="k-label-required" aria-hidden="true">*</span></label>
<div class="k-field">
<select id="country" name="country" autocomplete="country" required>
<option value="">Choose a country</option>
<option value="FI">Finland</option>
<option value="SE">Sweden</option>
<option value="NO">Norway</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
<k-select>
<label class="k-label" for="language">Language</label>
<div class="k-field">
<select id="language" name="language" required>
<option value="">Choose a language</option>
<option value="fi">Suomi</option>
<option value="sv">Svenska</option>
<option value="en">English</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
</k-stack>import { Select, Stack } from "@kesko/components";
export default () => (
<Stack>
<Select label="Large" size="lg" placeholder="Placeholder">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</Select>
<Select label="Medium" placeholder="Placeholder">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</Select>
</Stack>
);<k-stack>
<k-select size="lg">
<label class="k-label" for="large">Large</label>
<div class="k-field">
<select id="large">
<option value="">Placeholder</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
<k-select>
<label class="k-label" for="medium">Medium</label>
<div class="k-field">
<select id="medium">
<option value="">Placeholder</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
</k-stack>import { Button, Select, Stack } from "@kesko/components";
export default () => (
<form onSubmit={event => event.preventDefault()}>
<Stack>
<Select label="Country" name="country" placeholder="Choose a country" required>
<option value="FI">Finland</option>
<option value="SE">Sweden</option>
</Select>
<Select label="Delivery slot" name="slot" defaultValue="afternoon" error="That slot is no longer available.">
<option value="morning">8–12</option>
<option value="afternoon">12–16</option>
<option value="evening">16–20</option>
</Select>
<Select label="Store" name="store" defaultValue="sello" success="This store has every item in stock.">
<option value="sello">K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
</Select>
<Button type="submit">Submit</Button>
</Stack>
</form>
);<form>
<k-stack>
<k-select>
<label class="k-label" for="country">Country<span class="k-label-required" aria-hidden="true">*</span></label>
<div class="k-field">
<select id="country" name="country" required>
<option value="">Choose a country</option>
<option value="FI">Finland</option>
<option value="SE">Sweden</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
</k-select>
<k-select>
<label class="k-label" for="slot">Delivery slot</label>
<div class="k-field">
<select id="slot" name="slot" aria-describedby="slot-message" aria-invalid="true">
<option value="morning">8–12</option>
<option value="afternoon" selected>12–16</option>
<option value="evening">16–20</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
<k-field-message variant="error" role="alert"><svg viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M22.113 18.023L13.745 3.08c-.75-1.343-2.738-1.338-3.49 0L1.888 18.023C1.153 19.332 2.13 21 3.633 21h16.735c1.503 0 2.476-1.666 1.745-2.978zM20.367 19.5H3.633a.504.504 0 0 1-.435-.745l8.364-14.94a.506.506 0 0 1 .875 0l8.368 14.942a.501.501 0 0 1-.438.743zm-8.885-5.66l-.31-4.785c0-.115.08-.195.194-.195h1.265c.116 0 .196.08.196.195l-.3 4.613c0 .127-.058.217-.208.242l-.61.102c-.128.023-.217-.035-.23-.172zM13 16.14c0 .552-.403.978-1 .978s-1-.425-1-.978.403-.965 1-.965 1 .425 1 .965z" fill="currentColor" /></svg><span id="slot-message">That slot is no longer available.</span></k-field-message>
</k-select>
<k-select success>
<label class="k-label" for="store">Store</label>
<div class="k-field">
<select id="store" name="store" aria-describedby="store-message">
<option value="sello" selected>K-Citymarket Sello</option>
<option value="kamppi">K-Supermarket Kamppi</option>
</select>
<svg slot="end" viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.747 10.313l-6.465 6.464a.401.401 0 0 1-.565 0l-6.464-6.465a.401.401 0 0 1 0-.564l.495-.495a.401.401 0 0 1 .565 0L12 14.94l5.688-5.687a.401.401 0 0 1 .565 0l.495.495a.401.401 0 0 1 0 .565z" fill="currentColor" /></svg>
</div>
<k-field-message variant="success" role="status"><svg viewBox="0 0 24 24" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M17.5 8.182a.4.4 0 0 1 .055.563l-5.728 6.98a.748.748 0 0 1-.554.275h-.025a.745.745 0 0 1-.545-.235l-3.725-3.958a.397.397 0 0 1 .017-.564l.51-.48a.397.397 0 0 1 .565.017l3.14 3.338 5.185-6.32a.4.4 0 0 1 .563-.055l.54.445zm2.525-2.14a.396.396 0 0 0-.603-.047l-.505.505a.399.399 0 0 0-.035.52 8.45 8.45 0 0 1 1.62 4.982c0 4.688-3.812 8.5-8.5 8.5S3.5 16.687 3.5 12 7.313 3.5 12 3.5c1.86 0 3.58.602 4.983 1.62.16.117.38.105.52-.035l.505-.505a.4.4 0 0 0-.048-.603A9.945 9.945 0 0 0 12 2.002c-5.515 0-10 4.485-10 10s4.485 10 10 10 10-4.485 10-10c0-2.23-.735-4.292-1.975-5.957z" fill="currentColor" /></svg><span id="store-message">This store has every item in stock.</span></k-field-message>
</k-select>
<button class="k-button" type="submit">Submit</button>
</k-stack>
</form>Properties #
| Name | Description | Type | Default |
|---|---|---|---|
label | Label for the select. Always provide one, even when it is hidden with | ReactNode | — |
hideLabel | Hides the label visually while keeping it available to assistive technology. | boolean | false |
description | Assistive text shown below the control, such as what the choice affects. | ReactNode | — |
error | Optional error message for the select, shown instead of the built-in validation message. Also marks the control invalid for assistive technology. | ReactNode | — |
success | Optional success message for the select. Shown only while there is no error. A plain string is also announced to screen readers when it appears. | ReactNode | — |
size | The size of the select. | "md" | "lg" | "md" |
name | The name the value is submitted under. | string | — |
value | The value of the selected option. Pair with | string | — |
defaultValue | The value of the option selected at first in an uncontrolled field. | string | — |
form | The | string | — |
placeholder | Text shown while nothing is chosen. Renders an option with an empty value first, so a | string | — |
required | Requires a choice before the form submits. Draws the marker on the label and is announced to assistive technology. | boolean | false |
hideRequired | Hides the required marker on the label while keeping | boolean | false |
disabled | Disables the control. Blocks interaction and drops the value from the submitted data. | boolean | — |
autoComplete | Tells the browser what the value is for, so it can offer to fill it in, such as | string | — |
Events #
| Name | Description | Type |
|---|---|---|
onChange | Handler called when a different option is chosen. | (event: ChangeEvent<HTMLSelectElement>) => void |
onFocus | Handler called when the control receives focus. | (event: FocusEvent<HTMLSelectElement>) => void |
onBlur | Handler called when the control loses focus. | (event: FocusEvent<HTMLSelectElement>) => void |
Styles #
CSS custom properties provide finer-grained control than properties. See Styling API for more details. Prefer the Properties API when it suits your need.
| Name | Description | Default |
|---|---|---|
--k-select-bg | Overrides the background color. | var(--k-color-bg-base) |
--k-select-text | Overrides the text color. | var(--k-color-text-base) |
--k-select-border | Overrides the border color in every state. | var(--k-color-border-control) |
--k-select-radius | Overrides the border radius. | var(--k-radius-md) |
--k-select-inline-size | Overrides the width of the field. | 100% |
Accessibility #
Select is built on a native <select> and <label>, so it opens the browser’s own picker on every device and behaves as expected with assistive technologies.
- Always pass a
label. A screen reader reads it as the name, and clicking it focuses the control. If there is no room for it, passhideLabelrather than leaving it out. - Start from a real choice or a
placeholder. Without either, the first option is selected and submitted silently.placeholderadds an empty option, so arequiredselect stays invalid until a real option is picked. Don’t hide instructions in a preselected option. - Keep option text short and self-contained. The picker shows the text alone, without the label. Use
optgroupto group a long list rather than repeating a prefix on every option. - The
startslot is decorative. An icon inslot="start"is not read as part of the control’s name and should carryaria-hidden. - Avoid
disabledfor validation. A disabled control leaves the tab order and cannot explain itself. Keep it enabled and let the message say what is wrong. Disable single options that cannot be chosen right now, and say why in the option text. - Check contrast if you override colors. Text needs 4.5:1 against
--k-select-bg, and--k-select-borderneeds 3:1 against the surface the field sits on. Verify with the WebAIM contrast checker.
See the accessibility guidelines and the A11Y checklist for more details.
Usage #
There are two necessary parts to using the Select component. The @kesko/components package and the CSS Framework are required. Everything else is optional:
npm install @kesko/components @kesko/csspnpm add @kesko/components @kesko/cssyarn add @kesko/components @kesko/cssbun add @kesko/components @kesko/cssOnce installed, load the CSS Framework in your app’s entry point or root layout:
import "@kesko/css";Then, you can import the Select:
import { Select } from "@kesko/components";Projects without React can get the same styles from @kesko/css by importing the components stylesheet as well:
@import "@kesko/css";
@import "@kesko/css/components";Resources #
Usage guidelines
Learn how to use the component library with React, Next.js, or basic HTML.
Localization
How to translate the components for multiple languages.
CSS Framework
Utilities and tokens for everything the components don’t cover.
Themes
How to customize the component library theme.
Accessibility checklist
Interactive, browser-based Kesko accessibility checklist.