Skip to content

Conversation

julienbenac
Copy link
Contributor

📝 Description

This PR adds the data-required attribute to form field labels when the required prop is set to true. This enhancement provides better accessibility and styling capabilities for required form fields across all Zag form components.

This change was inspired by commit 011741e from Ark UI, ensuring consistency between the two libraries.

⛳️ Current behavior (updates)

Form field labels do not include any indication when a field is required, making it difficult for developers to consistently style required fields and provide proper accessibility indicators.

🚀 New behavior

All form field labels now include the data-required attribute when the required prop is true, providing consistent styling hooks and accessibility improvements across all form components. Only form components that already had a required property defined in their types were modified, ensuring backward compatibility and maintaining the existing API surface.

💣 Is this a breaking change (Yes/No):

No.

📝 Additional Information

This enhancement significantly improves the developer experience by providing a standardized, framework-agnostic way to style required form fields without the need for custom logic or manual attribute management, making it easier to create consistent and accessible user interfaces.

[data-required]::after {
  content: "*";
  color: red;
}

Copy link

changeset-bot bot commented Aug 31, 2025

🦋 Changeset detected

Latest commit: 5f18fec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 77 packages
Name Type
@zag-js/checkbox Patch
@zag-js/color-picker Patch
@zag-js/combobox Patch
@zag-js/editable Patch
@zag-js/file-upload Patch
@zag-js/number-input Patch
@zag-js/password-input Patch
@zag-js/pin-input Patch
@zag-js/rating-group Patch
@zag-js/select Patch
@zag-js/signature-pad Patch
@zag-js/switch Patch
@zag-js/tags-input Patch
@zag-js/anatomy-icons Patch
@zag-js/anatomy Patch
@zag-js/core Patch
@zag-js/docs Patch
@zag-js/preact Patch
@zag-js/react Patch
@zag-js/solid Patch
@zag-js/svelte Patch
@zag-js/vue Patch
@zag-js/accordion Patch
@zag-js/angle-slider Patch
@zag-js/async-list Patch
@zag-js/avatar Patch
@zag-js/carousel Patch
@zag-js/clipboard Patch
@zag-js/collapsible Patch
@zag-js/date-picker Patch
@zag-js/dialog Patch
@zag-js/floating-panel Patch
@zag-js/hover-card Patch
@zag-js/listbox Patch
@zag-js/menu Patch
@zag-js/navigation-menu Patch
@zag-js/pagination Patch
@zag-js/popover Patch
@zag-js/presence Patch
@zag-js/progress Patch
@zag-js/qr-code Patch
@zag-js/radio-group Patch
@zag-js/scroll-area Patch
@zag-js/slider Patch
@zag-js/splitter Patch
@zag-js/steps Patch
@zag-js/tabs Patch
@zag-js/timer Patch
@zag-js/toast Patch
@zag-js/toggle-group Patch
@zag-js/toggle Patch
@zag-js/tooltip Patch
@zag-js/tour Patch
@zag-js/tree-view Patch
@zag-js/store Patch
@zag-js/types Patch
@zag-js/aria-hidden Patch
@zag-js/auto-resize Patch
@zag-js/collection Patch
@zag-js/color-utils Patch
@zag-js/utils Patch
@zag-js/date-utils Patch
@zag-js/dismissable Patch
@zag-js/dom-query Patch
@zag-js/file-utils Patch
@zag-js/focus-trap Patch
@zag-js/focus-visible Patch
@zag-js/highlight-word Patch
@zag-js/i18n-utils Patch
@zag-js/interact-outside Patch
@zag-js/json-tree-utils Patch
@zag-js/live-region Patch
@zag-js/popper Patch
@zag-js/rect-utils Patch
@zag-js/remove-scroll Patch
@zag-js/scroll-snap Patch
@zag-js/stringify-state Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Aug 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
zag-nextjs Ready Ready Preview Sep 2, 2025 11:59am
zag-solid Ready Ready Preview Sep 2, 2025 11:59am
zag-svelte Ready Ready Preview Sep 2, 2025 11:59am
zag-vue Ready Ready Preview Sep 2, 2025 11:59am
zag-website Ready Ready Preview Sep 2, 2025 11:59am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants