0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Turns a form control off: it can't be focused, edited or activated, it is skipped by validation, and its value is not submitted. On a fieldset it disables every control inside.
Overview
disabled is a boolean attribute that switches a form control off. A disabled control can't be focused or activated, leaves the tab order, is barred from constraint validation and is left out of the submitted form data. On a <fieldset> it disables every control inside, except those in the fieldset's first <legend>.
<form-field><labelfor="email">Account email</label><inputtype="email"id="email"name="email"value="[email protected]"disabled /></form-field><selectname="plan"><option>Free</option><optionselected>Pro</option><optiondisabled>Enterprise (contact sales)</option></select><fieldsetdisabled><legend>Billing address (managed by your organisation)</legend><form-field><labelfor="street">Street</label><inputtype="text"id="street"name="street"value="18 Harbour Road" /></form-field></fieldset>
Values
Boolean: present means disabled. disabled="false" still disables; remove the attribute (or set el.disabled = false) to enable. A control is also disabled when it sits inside a disabled fieldset (outside its first legend), which :disabled reflects but the control's own disabled property does not.
Disabling the submit button inside the submit event drops its name/value from the form data and throws focus to <body>. Use data-loading: the button gets aria-disabled="true" and aria-busy="true", keeps focus, shows a spinner, and further clicks are ignored until the submission finishes.
A disabled button can't be focused, so a tooltip or title on it is never reached by keyboard. Put the reason in visible text instead, or keep the control focusable with aria-disabled and handle the click.
Reason in text
<buttontype="button"disabledaria-describedby="delete-reason">Delete account</button><pid="delete-reason">Transfer ownership of your 2 workspaces before deleting your account.</p>
Keeping a value but not the editing
Disabled values are not sent. If the server needs the value, use readonly on text fields, or pair a disabled <select> with a hidden input.
Buttons.:disabled and [aria-disabled="true"] both get opacity: 0.5 and a not-allowed cursor (src/native-elements/button/styles.css).
Text fields, selects, textareas.:disabled gets the raised surface (--color-surface-raised) and a not-allowed cursor, with no opacity (src/native-elements/input/styles.css).
Fieldsets.fieldset:disabled gets muted text and a dashed border, with no opacity of its own so the dimming doesn't compound with the controls' (src/native-elements/form/styles.css). In forced colours the text and border use GrayText.
Conditional sections.data-show-when, data-hide-when and data-wizard-if set disabled on every control in a section they hide, marked data-conditional-disabled, so hidden fields are neither validated nor submitted. Only marked controls are re-enabled; anything you disabled yourself stays disabled (src/lib/form-conditions.js).
Enhanced controls follow the state.data-stepper buttons lock when their input is disabled (or inside a disabled fieldset); data-upload ignores drops on a disabled input; data-select-all skips disabled checkboxes; data-autosave never restores into a disabled control.
Accessibility
Disabled controls leave the tab order, so keyboard and screen-reader users can miss them entirely. If users need to discover the control and learn why it is unavailable, use aria-disabled="true" and block the action in script; VB styles it the same as disabled for buttons.
Disabled controls are exempt from WCAG contrast minimums, but that doesn't make faint text readable. Say why the control is off in nearby text.
Don't use inert to make content "read-only". It removes the content from the accessibility tree as well as from interaction; use readonly or aria-disabled.
Don't disable the submit button until the form is valid. Users get no explanation; let them submit and show the errors.
Gotchas
disabled means nothing on <a>. A link has no disabled state: remove the href (it becomes a placeholder link) or render text instead.
Controls in a disabled fieldset report el.disabled === false. Test with el.matches(':disabled').
Firefox keeps a <button>'s script-set disabled state across a page reload. Add autocomplete="off" to the button if it should always start from the markup.
Disabling a focused control moves focus to <body>. Move focus somewhere useful first.
Related
readonly — not editable, still focusable and submitted