sveltelean
Version v0.18.0
AttributeValuesRead by
data-variantbutton, toggle contained | outlined | text; fields outlined | filled | standard; badge, alert, toast standard | filled | outlined; card elevation | outlined; progress linear | circular; avatar circular | rounded | squareCSS
data-colorprimary|secondary|error|warning|info|success|neutral, on the element or any ancestorCSS
data-sizesmall | medium (default) | largeCSS
Modifiersdata-full-width, data-icon-only, data-density="compact|comfortable" (inherited), the start-icon and end-icon parts, disabled, aria-disabled, aria-busy, aria-invalid, data-status="warning"CSS
Optionsdata-slean-side, data-slean-orientation, …CSS and the behavior

Button

Variant × color
contained
outlined
text
Code
<script lang="ts">
	import '@svelte-lean/styles/button.css';

	const variants = ['contained', 'outlined', 'text'];
	const colors = ['primary', 'secondary', 'error', 'warning', 'info', 'success', 'neutral'];
</script>

{#each variants as variant (variant)}
	{#each colors as color (color)}
		<button type="button" data-slean="button" data-variant={variant} data-color={color}>
			{color}
		</button>
	{/each}
{/each}
Every variant is drawn once from the current color, so any color works with any variant. Neutral is MUI's inherit: outlined and text take the text color and the border hairline; contained stays a neutral fill.
Sizes, icons, states, full width
Code
<script lang="ts">
	import '@svelte-lean/styles/button.css';
</script>

<button type="button" data-slean="button" data-size="small">Small</button>
<button type="button" data-slean="button">Medium</button>
<button type="button" data-slean="button" data-size="large">Large</button>

<button type="button" data-slean="button">
	<span data-slean-part="start-icon" aria-hidden="true"><CheckIcon /></span>
	Approve
</button>
<button type="button" data-slean="button" data-variant="outlined">
	Next
	<span data-slean-part="end-icon" aria-hidden="true"><ArrowIcon /></span>
</button>
<button type="button" data-slean="button" data-variant="text" data-color="neutral"
	data-icon-only aria-label="Close">
	<CloseIcon />
</button>

<button type="button" data-slean="button" aria-busy="true">Saving</button>
<button type="button" data-slean="button" disabled>Disabled</button>
<button type="button" data-slean="button" data-variant="outlined" aria-disabled="true">
	Not allowed
</button>

<button type="submit" data-slean="button" data-full-width>Create account</button>
Icons sit in the start-icon and end-icon parts; busy keeps the button focusable; aria-disabled keeps it in the tab order.

Badge and alert

Standard, filled, outlined × color
standard
primarysecondaryerrorwarninginfosuccessneutral
filled
primarysecondaryerrorwarninginfosuccessneutral
outlined
primarysecondaryerrorwarninginfosuccessneutral
standard

Payment received

Invoices sync every hour

Two seats left on this plan

The last deploy failed

filled

Payment received

Invoices sync every hour

Two seats left on this plan

The last deploy failed

outlined

Payment received

Invoices sync every hour

Two seats left on this plan

The last deploy failed

Code
<script lang="ts">
	import '@svelte-lean/styles/badge.css';
	import '@svelte-lean/styles/alert.css';

	const variants = ['standard', 'filled', 'outlined'];
	const colors = ['primary', 'secondary', 'error', 'warning', 'info', 'success', 'neutral'];
	const alerts = {
		success: 'Payment received',
		info: 'Invoices sync every hour',
		warning: 'Two seats left on this plan',
		error: 'The last deploy failed'
	};
</script>

{#each variants as variant (variant)}
	{#each colors as color (color)}
		<span data-slean="badge" data-variant={variant} data-color={color}>{color}</span>
	{/each}
{/each}

{#each variants as variant (variant)}
	{#each Object.entries(alerts) as [color, text] (color)}
		<div data-slean="alert" data-variant={variant} data-color={color}>
			<span data-slean-part="icon" aria-hidden="true"></span>
			<p data-slean-part="title">{text}</p>
		</div>
	{/each}
{/each}
Standard is the soft tint, filled the main color, outlined a line in the color. Alerts take the status icon of their color.

Fields

Outlined, filled, standard
outlined
$ USD
filled
$ USD
standard
$ USD
Code
<script lang="ts">
	import '@svelte-lean/styles/field.css';
	import '@svelte-lean/styles/input.css';
	import '@svelte-lean/styles/select.css';
</script>

{#each ['outlined', 'filled', 'standard'] as variant (variant)}
	<div data-slean="field">
		<label for="name-{variant}" data-slean-part="label">{variant}</label>
		<input id="name-{variant}" data-slean="input" data-variant={variant} placeholder="Name" />
	</div>
	<div data-slean="field">
		<label for="role-{variant}" data-slean-part="label">Role</label>
		<select id="role-{variant}" data-slean="select" data-variant={variant}>
			<option>Admin</option>
			<option>Member</option>
		</select>
	</div>
	<div data-slean="field">
		<label for="price-{variant}" data-slean-part="label">Price</label>
		<div data-slean="input" data-variant={variant}>
			<span data-slean-part="prefix">$</span>
			<input id="price-{variant}" inputmode="decimal" value="120" />
			<span data-slean-part="suffix">USD</span>
		</div>
	</div>
{/each}
The bare input, the bare native select and the input shell share the three shells; focus draws from the current color.
Sizes and states
small
medium
large

Enter a complete address.

Did you mean gmail.com?

Code
<!-- Sizes line up with the button of the same size. -->
{#each ['small', 'medium', 'large'] as size (size)}
	<input data-slean="input" data-size={size} aria-label="Search, {size}" placeholder={size} />
	<select data-slean="select" data-size={size} aria-label="Status, {size}">
		<option>Open</option>
	</select>
	<button type="button" data-slean="button" data-size={size}>Search</button>
{/each}

<!-- An error is aria-invalid, a warning data-status, disabled the platform's. -->
<div data-slean="field">
	<label for="email" data-slean-part="label">Email</label>
	<input id="email" data-slean="input" aria-invalid="true" aria-describedby="email-error"
		value="ada@" />
	<p id="email-error" data-slean-part="error">Enter a complete address.</p>
</div>
<div data-slean="field">
	<label for="domain" data-slean-part="label">Domain</label>
	<input id="domain" data-slean="input" data-status="warning" aria-describedby="domain-hint"
		value="gmial.com" />
	<p id="domain-hint" data-slean-part="description">Did you mean gmail.com?</p>
</div>
<div data-slean="field">
	<label for="workspace" data-slean-part="label">Workspace</label>
	<input id="workspace" data-slean="input" value="harbor" disabled />
</div>
A field of a size is as tall as the button of that size. Error, warning and disabled come from aria-invalid, data-status and disabled.

Density

Compact and comfortable
compact
comfortable
Code
<!-- data-density on any element changes the control heights of its subtree. -->
{#each ['compact', 'comfortable'] as density (density)}
	<form data-density={density}>
		<input data-slean="input" aria-label="Name" placeholder="Name" />
		<select data-slean="select" aria-label="Role"><option>Member</option></select>
		<button type="submit" data-slean="button">Invite</button>
	</form>
{/each}
data-density on a region changes the control heights of everything inside it.

Surfaces and indicators

Card, avatar, progress, skeleton

Elevation (default)

Outlined

Code
<script lang="ts">
	import '@svelte-lean/styles/card.css';
	import '@svelte-lean/styles/avatar.css';
	import '@svelte-lean/styles/progress.css';
	import '@svelte-lean/styles/skeleton.css';
</script>

<article data-slean="card"><p>Elevation (default)</p></article>
<article data-slean="card" data-variant="outlined"><p>Outlined</p></article>

{#each ['circular', 'rounded', 'square'] as variant (variant)}
	<span data-slean="avatar" data-variant={variant} role="img" aria-label="Ada Lovelace">
		<span data-slean-part="fallback" aria-hidden="true">AL</span>
	</span>
{/each}

{#each ['primary', 'success', 'warning', 'error'] as color (color)}
	<progress data-slean="progress" data-color={color} value="60" max="100"
		aria-label="{color} progress"></progress>
	<progress data-slean="progress" data-variant="circular" data-color={color}
		aria-label="Loading, {color}"></progress>
{/each}

{#each ['text', 'rectangular', 'rounded', 'circular'] as variant (variant)}
	<span data-slean="skeleton" data-variant={variant}></span>
{/each}
A card is elevated by default; outlined trades the shadow for a border. Progress takes the current color.

Overlays and orientation

data-size sets the inline size. Open state is [open], the entrance is @starting-style: no JavaScript.

Dialog sizes

Small

data-size="small"

Large

data-size="large"

Code
<script lang="ts">
	import '@svelte-lean/styles/button.css';
	import '@svelte-lean/styles/dialog.css';
</script>

<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" commandfor="dialog-sm" command="show-modal">
	Small dialog
</button>
<dialog id="dialog-sm" data-slean="dialog" data-size="small" aria-labelledby="dialog-sm-title">
	<header>
		<h2 id="dialog-sm-title">Small</h2>
		<p>data-size="small"</p>
	</header>
	<footer>
		<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" commandfor="dialog-sm" command="close">
			Close
		</button>
	</footer>
</dialog>

<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" commandfor="dialog-lg" command="show-modal">
	Large dialog
</button>
<dialog id="dialog-lg" data-slean="dialog" data-size="large" aria-labelledby="dialog-lg-title">
	<header>
		<h2 id="dialog-lg-title">Large</h2>
		<p>data-size="large"</p>
	</header>
	<footer>
		<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" commandfor="dialog-lg" command="close">
			Close
		</button>
	</footer>
</dialog>
Invoker commands open them; Escape, the backdrop or the button close them. The browser owns all of it.

data-slean-side and data-slean-align place the popover against its invoker with position-area and flip fallbacks; without anchor positioning it stays centered in the top layer.

Popover side and alignment
Default: below the invoker, centered.
data-slean-side="top"
data-slean-side="right"
data-slean-align="start"
data-slean-align="end"
Code
<script lang="ts">
	import '@svelte-lean/styles/button.css';
	import '@svelte-lean/styles/popover.css';
</script>

<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" popovertarget="pop-bottom">Bottom</button>
<div id="pop-bottom" popover data-slean="popover">Default: below the invoker, centered.</div>

<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" popovertarget="pop-top">Top</button>
<div id="pop-top" popover data-slean="popover" data-slean-side="top">data-slean-side="top"</div>

<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" popovertarget="pop-right">Right</button>
<div id="pop-right" popover data-slean="popover" data-slean-side="right">data-slean-side="right"</div>

<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" popovertarget="pop-start">Bottom, start</button>
<div id="pop-start" popover data-slean="popover" data-slean-align="start">data-slean-align="start"</div>

<button type="button" data-slean="button" data-variant="outlined" data-color="neutral" popovertarget="pop-end">Bottom, end</button>
<div id="pop-end" popover data-slean="popover" data-slean-align="end">data-slean-align="end"</div>
Side is physical; alignment is logical, so under dir=rtl start follows the invoker's right edge. Light dismiss is the browser's.
Vertical tabs
General preferences.
Code
<script lang="ts">
	// @svelte-lean/vite injects the behavior for the static data-slean="tabs" marker.
	import '@svelte-lean/styles/tabs.css';
	import { tabsParts } from '@svelte-lean/primitives/tabs';

	const t = tabsParts('prefs', { orientation: 'vertical' });
</script>

<div id="prefs" data-slean="tabs" data-slean-value="general" data-slean-orientation="vertical">
	<div {...t.list} aria-label="Preferences">
		<button {...t.tab('general', 'general')}>General</button>
		<button {...t.tab('privacy', 'general')}>Privacy</button>
	</div>
	<div {...t.panel('general', 'general')} tabindex="0">General preferences.</div>
	<div {...t.panel('privacy', 'general')} tabindex="0">Privacy preferences.</div>
</div>
data-slean-orientation="vertical": Up and Down move, Home and End jump; the indicator moves to the inline-end edge.

A color of your own

A variant is a shape, so a brand look is a color: one unlayered rule sets the six tokens of the current color, and every variant, size and state of the package draws from them.

app.css
/* A color the package does not know: an unlayered rule that sets the six tokens of the current
 * color. Every variant of every primitive draws from them (the outlined ink and line follow the
 * main tone by themselves), so data-color="brand" works on a button, a badge, an alert, a field or
 * a whole region. */
[data-color='brand'] {
	--slean-color-main: oklch(45% 0.12 300);
	--slean-color-light: oklch(60% 0.1 300);
	--slean-color-dark: oklch(40% 0.12 300);
	--slean-color-contrast-text: oklch(100% 0 0);
	--slean-color-soft: oklch(95% 0.03 300);
	--slean-color-soft-text: oklch(40% 0.12 300);
}
/* Its dark tones, under the package's two dark conditions. */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light'], .light) [data-color='brand'] {
		--slean-color-main: oklch(72% 0.12 300);
		--slean-color-dark: oklch(65% 0.12 300);
		--slean-color-contrast-text: oklch(18% 0.02 300);
		--slean-color-soft: oklch(28% 0.06 300);
		--slean-color-soft-text: oklch(86% 0.07 300);
	}
}
:is([data-theme='dark'], .dark) [data-color='brand'] {
	--slean-color-main: oklch(72% 0.12 300);
	--slean-color-dark: oklch(65% 0.12 300);
	--slean-color-contrast-text: oklch(18% 0.02 300);
	--slean-color-soft: oklch(28% 0.06 300);
	--slean-color-soft-text: oklch(86% 0.07 300);
}
A color of your own
Code
<script lang="ts">
	import '@svelte-lean/styles/button.css';
	import './app.css'; // the [data-color='brand'] rules above
</script>

<button type="button" data-slean="button" data-color="brand">Brand</button>
<button type="button" data-slean="button" data-color="brand" data-variant="outlined">Brand, outlined</button>
<button type="button" data-slean="button" data-color="brand" data-size="small">Brand, small</button>
Styled by the rule above; every variant and size still works.

Source: packages/styles/css, conventions in packages/styles/AGENTS.md.

Reference

PrimitiveTierdata-variantdata-sizeOptionsModifiersParts
button0outlined, textsmall, largenonedata-full-width, data-icon-onlystart-icon, end-icon
dialog0nonesmall, largedata-slean-side: right | left | top | bottomdata-sizeheader, title, description, footer, close
popover0nonenonedata-slean-side: top | left | right; data-slean-align: start | endnoneheader, title, description, footer
checkbox0nonesmall, largenonenonenone
checkbox-group1nonenonedata-slean-orientation: horizontalnoneall
radio-group0segmented, swatchsmall, largedata-slean-orientation: horizontaldata-full-widthnone
tabs1nonesmall, largedata-slean-orientation: verticaldata-full-widthlist, trigger, panel
menu1nonenonenonedata-colorgroup-label
listbox1nonenonedata-slean-orientation: horizontalnonelist, group-label
control–filled, standardsmall, largenonenoneinput, trigger, native, prefix, suffix, clear, separator, popup, group-label, empty
calendar1nonenonedata-slean-mode: range; data-slean-edge: start | end | bothnonegrid, header, title, month, year, previous, next, previous-year, next-year, day
date-picker2nonenonenonenoneseparator, input, clear, popup, footer, preset, presets, time, today, native
input1filled, standardsmall, largedata-slean-length: 4 | 8data-full-widthprefix, suffix, clear, reveal, decrement, increment
field0nonenonedata-slean-orientation: horizontalnonelabel, description, error
select2filled, standardsmall, largedata-slean-render: appdata-full-widthnative, trigger, value, placeholder, tag, remove, prefix, suffix, clear, popup
rating0nonesmall, largenonenonenone
slider1nativenonedata-slean-orientation: verticalnonenone
autocomplete2filled, standardsmall, largenonedata-full-widthclear, popup
accordion0ghostnonenonenonepanel
card0outlinednonenonenonemedia, header, title, description, body, footer, link
separator0nonenonenonenonenone
avatar0rounded, squaresmall, largenonedata-colorfallback
badge0filled, outlinedsmall, largenonenoneremove
kbd0nonenonenonenonenone
carousel0nonenonenonenoneviewport, slide
alert0filled, outlinednonenonenonetitle, actions, icon, close
progress0circularsmall, largenonenonenone
meter0nonesmall, largenonenonenone
skeleton0text, circular, rectangular, roundedsmall, largenonenonenone
breadcrumb0nonenonenonenonenone
nav0nonenonedata-slean-orientation: horizontalnonegroup-label, icon, actions
pagination0nonesmall, largenonenoneellipsis, previous, next
steps0nonenonedata-slean-orientation: verticalnonetitle, description, complete, error
toggle1text, outlinedsmall, largenonedata-icon-onlystart-icon, end-icon
toggle-group1text, outlinedsmall, largedata-slean-orientation: verticalnoneitem
toolbar1nonenonedata-slean-orientation: verticalnonenone
tree1nonenonenonenonelabel
toast2filled, outlinednonedata-slean-side: top; data-slean-align: start | centerdata-colorlist, item, title, description, actions, close
button-group0containednonedata-slean-orientation: verticaldata-variantnone
scroll-area0outlinednonedata-slean-orientation: horizontal; data-slean-fade: inlinenonenone
descriptions0outlinednonedata-slean-columns: 1 | 2 | 3 | 4; data-slean-layout: inlinenonenone
timeline0nonenonenonedata-colortitle, description, pending
empty0outlinednonenonenoneicon, title, description, actions
splitter2nonenonedata-slean-orientation: verticalnonepane, handle
sortable2nonenonedata-slean-orientation: horizontalnonehandle, previous, next
file-drop1picture-card, picture-circlenonenonenonearea, icon, output, list, input, item, media, title, description, remove
hover-card1nonenonedata-slean-side: top | left | rightnonenone
menubar1nonenonenonenonenone
hint1nonenonenonenonenone
copy1nonenonenonenoneicon
findable1nonenonenonenonefull

Generated: tiers from the primitives metadata, the rest from packages/styles/css/<name>.css.

State selectors

State comes from the platform and ARIA (:checked, [open], aria-selected), never a mirrored data-state, so server-rendered markup is styled correctly before any script runs.

PrimitiveState selectors used
button:disabled,:hover,:active,[aria-disabled="true"],[aria-busy="true"]
dialog:hover,:focus-visible,[open]
popover:popover-open
checkbox:checked,:indeterminate,:disabled,:user-invalid,:hover,[aria-invalid="true"]
checkbox-group:disabled
radio-group:checked,:disabled,:user-invalid,:focus-visible,:hover,[aria-invalid="true"]
tabs:hover,:disabled,:focus-visible,[aria-disabled="true"],[aria-selected="true"]
menu:hover,:disabled,:focus-visible,[aria-disabled="true"],[aria-checked],[aria-checked="true"]
listbox:hover,:focus-visible,[aria-disabled="true"],[aria-selected="true"]
control:focus-within,:user-invalid,:hover,:focus-visible,:disabled,:placeholder-shown,:checked,:popover-open,[aria-invalid="true"],[aria-expanded="true"],[aria-disabled="true"]
calendar:hover,[aria-disabled="true"],[aria-current="date"],[aria-selected="true"]
date-picker:hover,:placeholder-shown,:disabled,:focus-within,:popover-open,[aria-expanded="true"],[aria-pressed="true"]
input:placeholder-shown,:disabled,:focus-visible,:user-invalid,:hover,:focus-within,[aria-invalid="true"],[aria-pressed="true"]
field:user-invalid,:disabled,[aria-invalid="true"]
select:disabled,:user-invalid,:open,:checked,:hover,:focus-visible,[aria-invalid="true"]
rating:checked,:disabled,:hover,:focus-visible
slider:disabled,:focus-visible,:hover
autocomplete:focus-visible,:user-invalid,:disabled,:hover,[aria-invalid="true"]
accordion:focus-visible,:hover,[open]
card:focus-visible,:hover
separator[aria-orientation="vertical"]
avatarnone
badge:disabled,:focus-visible,:hover
kbdnone
carousel:disabled
alert:active,:hover,:focus-visible
progress:indeterminate
meternone
skeletonnone
breadcrumb:hover,:focus-visible,[aria-current="page"]
nav:hover,:focus-visible,[open],[aria-current="page"],[aria-disabled="true"]
pagination:focus-visible,:hover,[aria-current="page"]
steps[aria-current="step"]
toggle:disabled,:hover,:active,[aria-pressed="true"],[aria-pressed="mixed"],[aria-disabled="true"]
toggle-group:hover,:disabled,[aria-disabled="true"],[aria-pressed="true"]
toolbar[aria-pressed="true"]
tree:focus-visible,:hover,[aria-expanded="false"],[aria-expanded],[aria-expanded="true"],[aria-disabled="true"],[aria-selected="true"]
toast:active,:focus-visible,:hover
button-group:focus-visible,:hover,:disabled,[aria-disabled="true"]
scroll-areanone
descriptionsnone
timelinenone
emptynone
splitter:focus-visible,:hover,[aria-disabled="true"]
sortable:disabled,:hover,:focus-visible,[aria-disabled="true"]
file-drop:focus-visible,:disabled,:user-invalid,:hover,[aria-busy="true"]
hover-card:popover-open
menubar:popover-open,:focus-visible,:hover,[aria-disabled="true"]
hintnone
copy:disabled,[aria-disabled="true"]
findablenone