UI: Implement elevation prop for Box component #74621
UI: Implement elevation prop for Box component #74621Suhel-Shaikh-Mohammad wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Suhel-Shaikh-Mohammad! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Hi @aduth and @jameskoster! 👋 I've implemented elevation support for the Box component as discussed in #72784. This PR adds:
Since you both discussed this feature in the issue, I'd really appreciate your review and feedback! Label SuggestionThis PR requires a |
|
Thank you for the work, @Suhel-Shaikh-Mohammad ! As the Should we instead decide to move forward with the |
|
@ciampo Hii, Thanks a lot for the follow-up, totally appreciate it. I would like to know if the discussion regarding this is held in Slack community? |
What
Added elevation support to the Box component by introducing a new
elevationprop that allows developers to apply shadow effects using design tokens from the theme package.Why
The Box component is a foundational primitive that provides design system-based styling for layouts. Elevation (shadows) are a critical visual tool for creating depth, hierarchy, and visual distinction in UI interfaces. This addresses GitHub issue #72784, which outlined the need for elevation support as part of the Box component's comprehensive token integration.
Without elevation support, developers would need to manually apply box-shadow styles, bypassing the design system's centralized token management. This change ensures consistency across the application and maintains a single source of truth for all elevation styling.
How
The implementation leverages the existing elevation tokens defined in
packages/theme/tokens/elevation.json, which provides four elevation levels:x-small: For subtle shadows on grouped contentsmall: For contextual feedback without being intrusive (tooltips, snackbars)medium: For components offering additional actions (menus, command palette)large: For components requiring attention (modals, dialogs)The elevation prop directly maps to CSS variables following the pattern
--wpds-elevation-{level}, ensuring consistency with the design token naming convention.Testing
Unit Tests
npm run test:unitStorybook Verification
Story: WithElevation
Integration Points Tested
CSS Variable Resolution
--wpds-elevation-{level}CSS variableselevation.jsonRelated Issues
Addresses: #72784 - Component: Box
Related PRs
Checklist
npm run test:unit)