Components
Colors
Light
Brand
Status
Neutral
Dark
Brand
Status
Neutral
Button
- Pattern
.btn + [style] + [color] + [size] + [shape] + [state]- Styles
- solid (default),
btn-muted,btn-outline,btn-text - Colors
btn-primary,btn-secondary,btn-tertiary,btn-success,btn-warning,btn-error- Sizes
btn-sm, medium (default),btn-lg- Shapes
btn-circle,btn-square,btn-wide,btn-block- States
btn-active,disabled- Example
<button class="btn btn-primary btn-lg">Save</button>
Styles and colors
A style changes how the color is applied. Combine .btn-[style] with .btn-[color].
| Style | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Soliddefault |
|||||||
Muted.btn-muted |
|||||||
Outline.btn-outline |
|||||||
Text.btn-text |
Sizes
.btn-sm.btn.btn-lgShapes
Circle and square buttons keep a 1:1 ratio in every size. The circle is fully rounded, the square has no rounding.
.btn-circle.btn-sm.btn-circle.btn-circle.btn-lg.btn-square.btn-sm.btn-square.btn-square.btn-lg.btn-wide.btn-blockStates
.btn-activedisabledBadge
- Pattern
.badge + [style] + [color] + [size] + [shape]- Styles
- solid (default),
badge-muted,badge-outline,badge-dashed - Colors
badge-primary,badge-secondary,badge-tertiary,badge-success,badge-warning,badge-error- Sizes
badge-sm, medium (default),badge-lg- Shapes
- rounded (default),
badge-pill,badge-square - Example
<span class="badge badge-success badge-muted badge-lg">Active</span>
Styles and colors
A style changes how the color is applied. Combine .badge-[style] with .badge-[color].
| Style | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Soliddefault |
Solid | Solid | Solid | Solid | Solid | Solid | Solid |
Muted.badge-muted |
Muted | Muted | Muted | Muted | Muted | Muted | Muted |
Outline.badge-outline |
Outline | Outline | Outline | Outline | Outline | Outline | Outline |
Dashed.badge-dashed |
Dashed | Dashed | Dashed | Dashed | Dashed | Dashed | Dashed |
Sizes
.badge-sm.badge.badge-lgShapes
.badge.badge-pill.badge-squareLink
- Pattern
.link + [color] + [size] + [underline] + [special]- Colors
- neutral (default),
link-primary,link-secondary,link-tertiary,link-success,link-warning,link-error - Sizes
link-sm, medium (default),link-lg- Underline
- always (default),
link-underline-hover,link-underline-animate,link-underline-none - Special
link-external,link-disabled- Example
<a class="link link-primary link-lg link-underline-animate">Read more</a>
Underline and colors
Links change color on hover. .link-underline-none keeps the text neutral until hover.
| Underline | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Underlinedefault |
Underline | Underline | Underline | Underline | Underline | Underline | Underline |
Hover.link-underline-hover |
Hover | Hover | Hover | Hover | Hover | Hover | Hover |
Animate.link-underline-animate |
Animate | Animate | Animate | Animate | Animate | Animate | Animate |
None.link-underline-none |
None | None | None | None | None | None | None |
Sizes
Special
.link-external appends an external icon, .link-disabled mutes the link and blocks pointer events.
Card
- Pattern
.card + [style] + [color] + [size] + [layout] + [interactive]- Parts
card-media(image or video),card-body,card-title(headline)- Styles
- solid (default),
card-muted,card-outline,card-glass - Colors
card-primary,card-secondary,card-tertiary,card-success,card-warning,card-error- Sizes
card-sm, medium (default),card-lg- Layouts
card-reverse,card-side,card-side-reverse,card-media-background, each also aslayout-*- Interactive
card-hover,card-grow- Example
<div class="card card-muted card-primary card-side"><div class="card-media media">…</div><div class="card-body">…</div></div>
Structure
An element with Show as card renders a media part, a body with the headline as .card-title, the text and the call to action.
Body only
The body sets the padding and the gap between its children.
.card-body
With media
The media runs edge to edge.
.card-media + .card-body
.card-body > .cta-outer<div class="card media_text responsive-body-sm">
<div class="card-media media-image media">
<figure><img src="…" alt="…"></figure>
</div>
<div class="card-body responsive-body-sm text">
<h3 class="card-title responsive-headline-sm">Headline</h3>
<div class="rte"><p>Text</p></div>
<div class="cta-outer inline-flex flex-wrap gap-2 md:gap-4 mt-3">
<a href="…" class="btn btn-primary">Read more</a>
</div>
</div>
</div>
Styles and colors
A style changes how the color is applied. Combine .card-[style] with .card-[color].
| Style | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Soliddefault |
Solid
|
Solid
|
Solid
|
Solid
|
Solid
|
Solid
|
Solid
|
Muted.card-muted |
Muted
|
Muted
|
Muted
|
Muted
|
Muted
|
Muted
|
Muted
|
Outline.card-outline |
Outline
|
Outline
|
Outline
|
Outline
|
Outline
|
Outline
|
Outline
|
Glass
Glass blurs what lies behind it, so it needs an image or a colorful background.
.card-glass, .card-glass.card-[color]Sizes
The size sets the padding and the gap of the body.
Small
Padding and gap grow with the size.
.card-smDefault
Padding and gap grow with the size.
.cardLarge
Padding and gap grow with the size.
.card-lgLayouts
The side and background layouts style the > .media child. Elements that are not shown as a card get the same layouts as .layout-*.

Default
Media and body in one card.
.card
Reverse
Media and body in one card.
.card-reverseMedia background
Media and body in one card.
.card-media-background
Side
From the small breakpoint on, the media takes two fifths of the width. Below it, the card stacks.
.card-side
Side reverse
From the small breakpoint on, the media takes two fifths of the width. Below it, the card stacks.
.card-side-reverseInteractive
For cards that are links. Both effects also apply on keyboard focus and add a focus ring.
Hover
The shadow grows.
.card-hoverGrow
The card scales up.
.card-growCombined
Works with every style and color.
.card-muted.card-primary.card-hoverAlert
- Pattern
.alert + [style] + [color] + [size]- Sections
alert-icon,alert-content,alert-title,alert-description- Styles
- solid (default),
alert-muted,alert-outline,alert-dashed - Colors
alert-primary,alert-secondary,alert-tertiary,alert-success,alert-warning,alert-error- Sizes
alert-sm, medium (default),alert-lg- Example
<div class="alert alert-success alert-muted alert-lg">…</div>
Structure
Content goes in .alert-content. Icon, title and description are optional.
.alert > .alert-content.alert > .alert-icon + .alert-content > .alert-description.alert-content > .alert-title + .alert-description.alert > .alert-icon + .alert-content > .alert-title + .alert-descriptionStyles and colors
A style changes how the color is applied. Combine .alert-[style] with .alert-[color].
| Color | Solid | Muted | Outline | Dashed |
|---|---|---|---|---|
Default.alert |
Solid
|
Muted
|
Outline
|
Dashed
|
Primary.alert-primary |
Solid
|
Muted
|
Outline
|
Dashed
|
Secondary.alert-secondary |
Solid
|
Muted
|
Outline
|
Dashed
|
Tertiary.alert-tertiary |
Solid
|
Muted
|
Outline
|
Dashed
|
Success.alert-success |
Solid
|
Muted
|
Outline
|
Dashed
|
Warning.alert-warning |
Solid
|
Muted
|
Outline
|
Dashed
|
Error.alert-error |
Solid
|
Muted
|
Outline
|
Dashed
|
Sizes
.alert-sm.alert.alert-lgPagination
- Pattern
.pagination + [size] + [shape]- Markup
nav.pagination > [p] + ul > li > (a | strong), as rendered by the Contao pagination- Sizes
pagination-sm, medium (default),pagination-lg- Shapes
- rounded (default),
pagination-circle,pagination-square - States
- current
strong,a[aria-current="page"],a.active; disabled.disabled,[disabled] - Example
<nav class="pagination pagination-sm pagination-circle">…</nav>
Sizes
.pagination-sm.pagination.pagination-lgShapes
.pagination.pagination-circle.pagination-squareIcons
States
Items use the neutral surface, the current page the primary color.
strong current, .disabled previousBreadcrumb
Classes
- Pattern
.breadcrumb + [color] + [size]- Base
breadcrumb, ormod_breadcrumbon the Contao module (add modifiers in its CSS class field)- Colors
breadcrumb-primary,breadcrumb-secondary,breadcrumb-tertiary,breadcrumb-success,breadcrumb-warning,breadcrumb-error, the hover color of links and the ellipsis (default primary)- Sizes
breadcrumb-sm, medium (default),breadcrumb-lg, also applied to the collapsed dropdown- Parts
breadcrumb-separator(SVG or text),breadcrumb-ellipsis,breadcrumb-ellipsis-btnandbreadcrumb-dropdown(created by the controller)- States
aria-current="page"oractiveon the currentli- Example
<nav class="breadcrumb breadcrumb-secondary breadcrumb-sm" aria-label="Breadcrumb">…</nav>
Stimulus controller
- Controller
data-controller="breadcrumb"on thenav- Targets
liston theul,itemon every collapsibleli- Values
max-itemscollapses when there are more items (default 4),breakpointcollapses below this viewport width in px (default 640)- Behavior
- Checked once on page load, not on resize. Collapsing hides every
itemand lists it in a popover behind an ellipsis button. Entries without the target, like home and the current page, stay visible. - Example
<nav class="breadcrumb" data-controller="breadcrumb" data-breadcrumb-max-items-value="3">
Responsive collapse
Four items do not exceed the default of four, so this trail is expanded on wide screens and collapsed below 640px. Reload after resizing.
data-controller="breadcrumb"Colors
data-breadcrumb-max-items-value="3" forces the collapse. Hover the links and the ellipsis to see the color.
.breadcrumb-primary.breadcrumb-secondary.breadcrumb-tertiary.breadcrumb-success.breadcrumb-warning.breadcrumb-errorSizes
Open the ellipsis to see the dropdown follow the size.
.breadcrumb-sm.breadcrumb.breadcrumb-lgPopover and dropdown
Classes
- Pattern
.popover-content + [preset] + [size]- Presets
popover-dropdown,popover-tooltip- Sizes
popover-sm, medium (default),popover-lg- Arrow
popover-arrow(optional, positioned by the controller)- Menu
dropdown-menu,dropdown-item,dropdown-item-shortcut,dropdown-separator,dropdown-label- States
activeoraria-selected="true",disabledoraria-disabled="true"on adropdown-item- Example
<div class="popover-content popover-tooltip popover-sm" data-popover-target="content">Hint</div>
Stimulus controller
- Controller
data-controller="popover"on the wrapper- Targets
trigger,content,arrow- Values
placementtop, bottom (default), left, right ·alignmentstart, center (default), end ·triggerclick (default), hover ·offsetgap in px (default 8) ·flipat the viewport edge (default true)- Actions
click->popover#toggleon a click trigger,click->popover#closeon a close button- Events
popover:opened,popover:closed- Behavior
- Closes on an outside click and on Escape, repositions on scroll and resize
- Example
<div data-controller="popover" data-popover-placement-value="top">
Placement
Set with data-popover-placement-value. A click trigger needs data-action="click->popover#toggle".
placement="top"placement="bottom"placement="left"placement="right"Alignment
Set with data-popover-alignment-value. Aligns the popover along the placement axis.
alignment="start"alignment="center"alignment="end"Trigger
Set with data-popover-trigger-value. Hover works without an action, click needs one.
trigger="click"trigger="hover"Presets
.popover-content.popover-dropdown.popover-tooltipSizes
.popover-sm.popover-content.popover-lgTooltip sizes
.popover-tooltip has its own, smaller scale.
.popover-tooltip.popover-sm.popover-tooltip.popover-tooltip.popover-lgDropdown menu
Combine .popover-dropdown with the menu classes.
Interactive content
Popovers can hold forms and buttons. A button with data-action="click->popover#close" closes it.
Input
- Pattern
.form-input + [style] + [color] + [size] + [state]- Styles
- outline (default),
input-muted - Colors
input-primary,input-secondary,input-tertiary,input-success,input-warning,input-error- Sizes
input-sm, medium (default),input-lg- Labels
label-text,label-required,helper-text,success-text,error-text- Floating label
input-floating>form-input+input-floating-label- Icons
input-group+has-icon-left/has-icon-right>input-icon- States
is-valid,is-invalid,disabled,readonly- Example
<input class="form-input input-primary input-lg" placeholder="Enter text">
Structure
A field is a .label-text, the input and an optional .helper-text below it.
.label-text + .form-input + .helper-text.label-text.label-requiredStyles and colors
The color tints the border and the focus ring, .input-muted adds a tinted background.
| Style | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Outlinedefault |
|||||||
Muted.input-muted |
Sizes
.input-sm.form-input.input-lgFloating label
The label sits inside the field and moves onto the border on focus or once the field has a value. Set placeholder=" ", a real placeholder only shows while the field is focused.
.input-floating.input-floating .input-primaryplaceholder="you@example.com"Limitations
The floated label covers the border with its own background, bg-neutral-surface-1 by default. On another background, add the same class to .input-floating: bg-neutral-surface-{1|2|3}, bg-{primary|secondary|tertiary}-solid or bg-status-{success|warning|error}-solid. Opacity variants such as bg-primary/10 are not supported.
Avoid .input-muted with a floating label: the tinted field and the solid label background do not match.
.input-mutedIcons
Wrap the input in .input-group with .has-icon-left and/or .has-icon-right. Each icon is a .input-icon before or after the input.
.input-group.has-icon-left.input-group.has-icon-right.has-icon-left.has-icon-rightStates
.is-valid + .success-text.is-invalid + .error-textdisabledreadonlyInput number
Classes
- Pattern
[layout] > .form-input + [style] + [color] + [size], plus two.input-number-btn- Layouts
input-number(buttons right),input-number-center(buttons on both sides)- Styles
- outline (default),
input-mutedon the input - Colors
input-primary,input-secondary,input-tertiary,input-success,input-warning,input-erroron the input, the buttons follow- Sizes
input-sm, medium (default),input-lgon the input, the buttons follow- States
disabledon the input and both buttons
Stimulus controller
- Controller
data-controller="input-number"on the layout wrapper- Target
data-input-number-target="input"on the input- Actions
click->input-number#decrementandclick->input-number#incrementon the buttons,input->input-number#inputChangedon the input- Attributes
min,maxandstepon the input
Layouts
The HTML order sets the layout: the buttons follow the input in .input-number and surround it in .input-number-center.
.input-number.input-number-center<div class="input-number" data-controller="input-number">
<input type="number" class="form-input" data-input-number-target="input" data-action="input->input-number#inputChanged" value="1" min="0" max="100">
<button type="button" class="input-number-btn" data-action="click->input-number#decrement">−</button>
<button type="button" class="input-number-btn" data-action="click->input-number#increment">+</button>
</div>
<div class="input-number-center" data-controller="input-number">
<button type="button" class="input-number-btn" data-action="click->input-number#decrement">−</button>
<input type="number" class="form-input" data-input-number-target="input" data-action="input->input-number#inputChanged" value="1" min="0" max="100">
<button type="button" class="input-number-btn" data-action="click->input-number#increment">+</button>
</div>
Styles and colors
Style and color classes go on the input, the buttons pick up the color automatically.
| Layout | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Buttons right, outline.input-number |
|
|
|
|
|
|
|
Centered, outline.input-number-center |
|
|
|
|
|
|
|
Buttons right, muted.input-number + .input-muted |
|
|
|
|
|
|
|
Centered, muted.input-number-center + .input-muted |
|
|
|
|
|
|
|
Sizes
The buttons scale with the size class of the input.
.input-sm.form-input.input-lgMin, max and step
The controller reads min, max and step from the input and disables a button once its limit is reached.
min="0" max="10"step="5"step="0.5"States
disabledTextarea
- Pattern
.form-textarea + [style] + [color] + [size] + [resize] + [state]- Styles
- outline (default),
textarea-muted - Colors
textarea-primary,textarea-secondary,textarea-tertiary,textarea-success,textarea-warning,textarea-error- Sizes
textarea-sm, medium (default),textarea-lg- Labels
label-text,label-required,helper-text,success-text,error-text- Floating label
textarea-floating>form-textarea+textarea-floating-label- Resize
- vertical (default),
resize-none,resize-x,resize-both - States
is-valid,is-invalid,disabled,readonly- Example
<textarea class="form-textarea textarea-primary" placeholder="Enter message"></textarea>
Structure
A field is a .label-text, the textarea and an optional .helper-text below it.
.label-text + .form-textarea + .helper-text.label-text.label-requiredStyles and colors
The color tints the border and the focus ring, .textarea-muted adds a tinted background.
| Style | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Outlinedefault |
|||||||
Muted.textarea-muted |
Sizes
A size sets the padding, the font size and the minimum height.
.textarea-sm.form-textarea.textarea-lgFloating label
The label sits in the first line and moves onto the border on focus or once the field has a value. Set placeholder=" ". The background limitations of the input floating label apply here too.
.textarea-floating.textarea-floating .textarea-primaryResize
Textareas resize vertically by default.
.resize-none.resize-x.resize-bothStates
.is-valid + .success-text.is-invalid + .error-textdisabledreadonlySelect
- Pattern
.form-select + [style] + [color] + [size] + [state]- Styles
- outline (default),
select-muted - Colors
select-primary,select-secondary,select-tertiary,select-success,select-warning,select-error- Sizes
select-sm, medium (default),select-lg- Labels
label-text,label-required,helper-text,success-text,error-text- Floating label
select-floating>form-select+select-floating-label- Icons
select-group+has-icon-left>select-icon(leading only)- States
is-valid,is-invalid,disabled- Example
<select class="form-select select-primary select-lg">…</select>
Structure
A field is a .label-text, the select and an optional .helper-text below it. An empty first option is shown in the placeholder color.
.label-text + .form-select + .helper-text.label-text.label-required<optgroup label="…">Styles and colors
The color tints the border and the focus ring, .select-muted adds a tinted background.
| Style | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Outlinedefault |
|||||||
Muted.select-muted |
Sizes
.select-sm.form-select.select-lgFloating label
Unlike the input, the label always stays floated, since a select always shows a value. The background limitations of the input floating label apply here too.
.select-floating.select-floating .select-primaryIcons
Wrap the select in .select-group.has-icon-left with a .select-icon before it. The icon spacing follows the size. There is no trailing icon, that side holds the arrow.
.select-group.has-icon-left .select-sm.select-group.has-icon-left.select-group.has-icon-left .select-lgStates
.is-valid + .success-text.is-invalid + .error-textdisabledCheckbox
- Pattern
.form-checkbox + [color] + [size]- Colors
checkbox-primary,checkbox-secondary,checkbox-tertiary,checkbox-success,checkbox-warning,checkbox-error- Sizes
checkbox-sm, medium (default),checkbox-lg- States
checked,indeterminate(JavaScript),disabled- Markup
span > input + label, as Contao renders every option- Example
<span><input type="checkbox" id="terms" class="form-checkbox checkbox-primary"><label for="terms">I agree</label></span>
Colors
The color sets the border and fills the box once it is checked.
.form-checkbox.checkbox-primary.checkbox-secondary.checkbox-tertiary.checkbox-success.checkbox-warning.checkbox-errorSizes
The label next to the checkbox scales with it.
.checkbox-sm.form-checkbox.checkbox-lgStates
Indeterminate is a property, not an attribute. It is set with element.indeterminate = true and shows a line instead of the checkmark.
checkedindeterminatedisabledchecked disabledRadio
- Pattern
.form-radio + [color] + [size]- Colors
radio-primary,radio-secondary,radio-tertiary,radio-success,radio-warning,radio-error- Sizes
radio-sm, medium (default),radio-lg- States
checked,disabled- Markup
span > input + label, as Contao renders every option- Example
<span><input type="radio" name="plan" id="plan-basic" class="form-radio radio-primary"><label for="plan-basic">Basic</label></span>
Colors
The color sets the ring and the dot.
.form-radio.radio-primary.radio-secondary.radio-tertiary.radio-success.radio-warning.radio-errorSizes
The label next to the radio scales with it.
.radio-sm.form-radio.radio-lgStates
Radios with the same name form a group, checking one unchecks the others.
checkeddisabledchecked disabledSwitch
- Pattern
.form-switch + [style] + [color] + [size]- Styles
- solid (default),
switch-outline - Colors
switch-primary,switch-secondary,switch-tertiary,switch-success,switch-warning,switch-error- Sizes
switch-sm, medium (default),switch-lg- States
checked,disabled- Markup
label > input + span. Contao form fields render checkboxes, the switch is for custom markup.- Example
<label><input type="checkbox" class="form-switch switch-primary"><span>Notifications</span></label>
Styles and colors
The color fills the track once the switch is on. Outline keeps the track transparent and colors the border and the thumb.
| Style | Default | Primary | Secondary | Tertiary | Success | Warning | Error |
|---|---|---|---|---|---|---|---|
Soliddefault |
|||||||
Outline.switch-outline |
Sizes
.switch-sm.form-switch.switch-lgStates
checkeddisabledchecked disabledRange
Classes
- Pattern
.widget-range + [color] > .form-range + [size] + [fill]- Colors
range-primary,range-secondary,range-tertiary,range-success,range-warning,range-error, on the wrapper- Sizes
range-sm, medium (default),range-lg, on the input- Fill
range-fillon the input, needs therangecontroller- Helper
range-colorsets the text color to the wrapper color- States
disabled- Wrapper
- Contao renders every range field inside
.widget.widget-rangeand puts the field color there. The fill and the value display are siblings of the input and inherit the color from the wrapper. - Example
<div class="widget-range range-primary"><input type="range" class="form-range range-lg"></div>
Colors
Without the fill, the color shows on the thumb.
.widget-range.range-primary.range-secondary.range-tertiary.range-success.range-warning.range-errorSizes
.range-sm.form-range.range-lgStates
disabledStimulus controller
The range controller fills the track up to the thumb and shows the current value.
- Controller
data-controller="range"on the.widget-rangewrapper- Targets
data-range-target="input"withdata-action="input->range#update"on the input,data-range-target="value"(optional) on the element that shows the value- Values
data-range-suffix-valueis appended to the value, e.g.%.data-range-locale-valuesets the number format, the browser locale is the default.- Fill
- The controller sets
--range-fill-percenton the input,.range-fillpaints it
Fill
.range-fill.range-primary .range-fill.range-secondary .range-fill.range-tertiary .range-fill.range-success .range-fill.range-warning .range-fill.range-error .range-fillValue display
.range-color gives the value the wrapper color. The fill is optional, min, max and step work as usual.
step="10"<div class="widget-range range-success" data-controller="range" data-range-suffix-value=" GB">
<label class="label-text" for="storage">Storage limit</label>
<span class="range-color" data-range-target="value">50</span>
<input type="range" id="storage" class="form-range range-fill range-lg"
data-range-target="input"
data-action="input->range#update"
min="10" max="100" step="10" value="50">
</div>
Theme toggle
Toggle template
- Template
@Contao/kiss_component/theme/_toggle.html.twig, brings its own theme controller- Variables
sizein px (default 24),class,attributes,button_attributes- Block
theme_toggle_icon- Classes
theme-toggleon the button,theme-toggle__iconon the SVG- Animation
- The sun rays scale down and fade out, a mask slides in to form the crescent, the icon tilts by −45° in dark mode and wiggles on hover, all with spring easing
Stimulus controller
- Controller
data-controller="theme"- Modes
light,dark,system(follows the OS preference, used when nothing is stored)- Actions
theme#toggleswitches between light and dark (and leaves system mode),theme#setsets the mode from the input'svalue- Targets
toggle(checked in dark mode),radioandselect(synced with the mode),lightIconanddarkIcon(shown in their mode)- Values
storage-key, thelocalStoragekey (defaulttheme)- Events
theme:changewith{ mode, theme, isDark }on the element and the document- Sync
- Every theme controller on the page stays in sync
Sun and moon toggle
Include the template, no further setup is needed.
size: 32size: 48{{ include('@Contao/kiss_component/theme/_toggle.html.twig') }}
{{ include('@Contao/kiss_component/theme/_toggle.html.twig', {size: 32}) }}
{{ include('@Contao/kiss_component/theme/_toggle.html.twig', {class: 'my-class'}) }}
Light and dark
Two-way controls call theme#toggle. A toggle target is checked while dark mode is active.
.form-switch.form-checkboxlightIcon, darkIcon<label data-controller="theme">
<input type="checkbox" class="form-switch" data-theme-target="toggle" data-action="change->theme#toggle">
</label>
<button class="btn" data-controller="theme" data-action="click->theme#toggle">
<span data-theme-target="lightIcon">Light mode</span>
<span data-theme-target="darkIcon" style="display: none;">Dark mode</span>
</button>
Light, dark and system
Three-way controls add system, which follows the OS preference. They call theme#set, which reads the input's value, and the controller selects the stored mode on page load.
select targetradio targetThe segmented control and the pill buttons hide the radios with .sr-only, which keeps them accessible. .peer on the input lets peer-checked: utilities style the visible sibling.
Events
document.addEventListener('theme:change', (event) => {
console.log(event.detail); // { mode: 'dark', theme: 'dark', isDark: true }
});
Date range picker
Overview
- Pattern
[data-controller="date-range-picker"] > input.form-input + input.form-input- Library
- vanillajs-datepicker (
DateRangePicker) - Inputs
- The first two inputs inside the wrapper become the start and the end field
- Behaviour
- The calendar highlights the range between both dates. Past dates are disabled (
minDateis today). - Styles
- The popup uses the library stylesheet. Import
vanillajs-datepicker/css/datepicker.csswithlayer(components)in the project.
Date range
data-controller="date-range-picker"<div data-controller="date-range-picker">
<input type="text" class="form-input date-from" placeholder="Arrival">
<input type="text" class="form-input date-to" placeholder="Departure">
</div>
Stimulus controller
- Controller
data-controller="date-range-picker"on the wrapper around both inputs- Values
data-date-range-picker-format-valuesets the date format, e.g.yyyy-mm-dd.data-date-range-picker-language-valuesets the locale, e.g.de. The page language is the default, English the fallback.