Base

  • Colors
  • Icons
  • Logos
  • Shadows and Elevations
  • Spacing
  • Typography

Components

  • Accordion
  • Avatars
  • Badges
  • Buttons
  • Cards
  • Character Counter
  • Device Type Icons
  • Draggables
  • Dropdowns
  • Droppables
  • Expandable image
  • Filters
  • Gallery card
  • Icon Button
  • Indicators
  • Lightbox image
  • Lists
  • Loading
  • Messages
  • Pictogram
  • Poster Play
  • Progress bar
  • QR Code
  • Rating stars
  • Row Selector
  • Segmented Controls
  • Sentiment
  • Split View
  • Tables
  • Tags
  • Tester vitals
  • Toggle button
  • Typeahead

Form

  • Card Select
  • Checkbox
  • Combobox
  • Form Rule
  • Hint
  • Input
  • Input Title
  • Label
  • Multi-select List
  • Search
  • Select
  • Single-select List
  • Sliders
  • Switch
  • Text Area

Layout

  • Containers
  • Layers
  • Layout
  • Split Layout
  • Wrappers

Navigation

  • Context Switcher
  • Nav bar
  • Navigation
  • Pagination
  • Sidebar Navigation
  • Step Navigation
  • Tabs

Overlay

  • Banners
  • Bulk Selector
  • Modals
  • Popovers
  • Toast
  • Tooltips
  • User Notifications

Patterns

  • Full Page Message
  • Question card & Group Questions Container

Visualizations

  • Data Colors

Select

Make a selection using a dropdown.

Select

Character >
Expand Copy
<!-- for demo only -->

<tk-highlight id="exampleSelectOutput" class="l-block"></tk-highlight>

<tk-select
id="exampleSelect"
options="defaultOptions"

> <span slot="label" class="l-block t-heavy">Character</span> > </tk-select>

<!-- only required for use outside of a framework -->
<script>
  loadScript(document.currentScript);

  exampleSelect.addEventListener('valueChanged', ($event) => {
    exampleSelectOutput.innerHTML = `📣 valueChanged emitted: ${$event.detail}`;
  });
</script>

Description

This dropdown text pattern is primarily used in forms to make a selection. The width is tied to the option with the longest character count.

Label text and label size

Medium Label
Large Label
Expand Copy
<tk-select options="defaultOptions">
<span slot="label" class="l-block t-heavy">Medium Label</span>
</tk-select>

<hr/>
<tk-select options="defaultOptions">
  <span slot="label" class="l-block t-large t-heavy">Large Label</span>
</tk-select>
<!-- only required for use outside of a framework -->
<script>
  loadScript(document.currentScript);
</script>

Description

Provide a label for the component by slotting a span element as shown in the example. The text size of the label can be controlled with our typography utility classes.

Grouping options

Character
Expand Copy
<tk-select options="defaultOptions">
<span slot="label" class="l-block t-heavy">Character</span>
</tk-select>

<!-- only required for use outside of a framework -->
<script>
  let options = [
    {
      "label": "House Gryffindor",
      "options": [
        { "label": "Hermione Granger", "value": "Value5" },
        { "label": "Ron Weasley", "value": "Value7" },
        { "label": "Harry Potter", "value": "Value6" }
      ]
    },
    {
      "label": "House Slytherin",
      "options": [
        { "label": "Draco Malfoy", "value": "Value8"}
      ]
    },
    {
      "options": [
        { "label": "Albus Dumbledore", "value": "Value1"},
        { "label": "Severus Snape", "value": "Value4" }
      ]
    },
  ];
  loadScript(document.currentScript, options);
</script>

Description

A native select allows for grouping its options with an optgroup tag. To achieve this for tk-select, add a "label": "Label here" key/value pair inside of the options data model. Expand the code example for more details.

Type

Secondary type >
Outline type
Expand Copy
<tk-select
options="defaultOptions"
type="secondary"

> <span slot="label" class="l-block t-heavy">Secondary type</span> > </tk-select>

<!-- only required for use outside of a framework -->
<script>
  loadScript(document.currentScript);
</script>
<hr>
<tk-select
  options="defaultOptions"
  type="outline"
>
  <span slot="label" class="l-block t-heavy">Outline type</span>
</tk-select>
<!-- only required for use outside of a framework -->
<script>
  loadScript(document.currentScript);
</script>

Description

The component comes in different types of appearances. Pass the desired value for the type prop to render it accordingly.

Prefilled value

Character
Expand Copy
<tk-select value="Value6" options="defaultOptions">
<span slot="label" class="l-block t-heavy">Character</span>
</tk-select>

<!-- only required for use outside of a framework -->
<script>
  loadScript(document.currentScript);
</script>

Description

Pass tk-select a value prop which matches the value of the option that you’d like prefilled.

Size

Size: determined by widest option >
Size: util class
Size: util class Size: util class Size: util class

Size: Large
Expand Copy
<tk-select
options="defaultOptions"
type="secondary"
class="mb-2x"

> <span slot="label" class="l-block t-heavy">Size: determined by widest option</span> > </tk-select>

<hr>
<tk-select
  options="defaultOptions"
  type="secondary"
  class="mb-2x l-block"
>
  <span slot="label" class="l-block t-heavy">Size: util class</span>
</tk-select>
<hr>
<div class="l-grid l-col-3 l-sm-col-1 l-gap-2x">
<tk-select
  options="defaultOptions"
  type="secondary"
  class="l-block"
>
  <span slot="label" class="l-block t-heavy">Size: util class</span>
</tk-select>
<tk-select
  options="defaultOptions"
  type="secondary"
  class="l-block"
>
  <span slot="label" class="l-block t-heavy">Size: util class</span>
</tk-select>
<tk-select
  options="defaultOptions"
  type="secondary"
  class="l-block"
>
  <span slot="label" class="l-block t-heavy">Size: util class</span>
</tk-select>
</div>
<hr>
<tk-select
  options="defaultOptions"
  type="secondary"
  class="mb-2x l-block"
  size="large"
>
  <span slot="label" class="l-block t-heavy">Size: Large</span>
</tk-select>
<script>
  loadScript(document.currentScript);
</script>

Description

By default, the width of a select is tied to the option with the longest character count. To change the width, the util class l-block can be used to make a select as wide as its parent.

Error state

Error state >
Expand Copy
<tk-select
options="defaultOptions"
error

> <span slot="label" class="l-block t-heavy">Error state</span> > </tk-select>

<!-- only required for use outside of a framework -->
<script>
  loadScript(document.currentScript);
</script>

Description

To render the component in a failed validation state, pass an error prop.

Disabled state

Disabled state for entire menu >
Disabled state for individual options
Expand Copy
<tk-select
options="defaultOptions"
disabled

> <span slot="label" class="l-block t-heavy">Disabled state for entire menu</span> > </tk-select>

<hr>
<tk-select options="defaultOptions">
  <span slot="label" class="l-block t-heavy">Disabled state for individual options</span>
</tk-select>
<!-- only required for use outside of a framework -->
<script>
  options = [
    {
      "options": [
        { "label": "Hermione Granger", "value": "Value5" },
        { "label": "Ron Weasley", "value": "Value7", "disabled": true },
        { "label": "Harry Potter", "value": "Value6" }
      ]
    },
  ];
  const components = document.currentScript.parentNode.querySelectorAll('tk-select');
  components[0].options = defaultOptions;
  components[1].options = options;
</script>

Description

If the entire tk-select menu needs to be rendered in a disabled state, pass the disabled prop. If you need this for individual options, add a "disabled": true key/value pair inside of the options data model. Expand the code example for more details.

Required

Character (required) >
Expand Copy
<tk-select
options="defaultOptions"
required

> <span slot="label" class="l-block t-heavy">Character (required)</span> > </tk-select>

<script>
  options = [
    {
      "options": [
        { "label": "Please select", "value": ""},
        ...defaultOptions[0].options
      ]
    },
  ];
  loadScript(document.currentScript, options);
</script>

Description

If the tk-select is required to have a value and can’t be left empty, pass a required prop. This will also render validation styling.

Hint

Character Select your favourite character
Character Select your favourite character
Expand Copy
<tk-select options="defaultOptions">
<span slot="label" class="l-block t-heavy">Character</span>
<span slot="hint" class="l-inline-flex l-v-center">
<tk-icon name="heart" size="xs" class="mr-1x" variant="solid"></tk-icon>
Select your favourite character
</span>
</tk-select>

<hr>
<tk-select
  options="defaultOptions"
  error
>
  <span slot="label" class="l-block t-heavy">Character</span>
  <span slot="hint" class="l-inline-flex l-v-center">
    <tk-icon name="heart" size="xs" class="mr-1x" variant="solid"></tk-icon>
    Select your favourite character
  </span>
</tk-select>
<script>
  loadScript(document.currentScript);
</script>

Description

The tk-select renders a hint containing any content injected into the hint slot, when supplied. When the error prop is also true, the hint is rendered in error state, aria-invalid="true" is added to the select and the aria-errormessage value of the select is set to the id of the tk-select.

Text size

Default text size
Medium text size
Expand Copy
<tk-select options="defaultOptions">
<span slot="label" class="l-block t-heavy">Default text size</span>
</tk-select>

<hr>
<tk-select
  options="defaultOptions"
  size="medium"
>
  <span slot="label" class="l-block t-heavy">Medium text size</span>
</tk-select>
<!-- only required for use outside of a framework -->
<script>
  loadScript(document.currentScript);
</script>

Description

Set the size prop to medium to set the font size within the select to 16px. By default, the size is 14px.

Accessibility

  • Selects should have a descriptive label. It can be passed to the component by using a span element with a slot="label" attribute on it. Code examples provided above.