Skip to content

Better way to support density switch on breakpoints #3303

@origami-z

Description

@origami-z

Area

UI Components

The problem

Some site needs to switch density depending on breakpoints, Salt website does this as well. There isn't a straightforward way to implement this at the moment, where density needs to be provided as a prop to SaltProvider but breakpoint can only be accessed inside the provider (e.g., via nested component). It creates unnecessary nesting to implement this feature.

The solution

Add callback to SaltProvider / its useDensity hook to update density, similar to POC for mode in #3237.

Alternatives and examples

Not so ideal implementation with nested component just for a callback: https://stackblitz.com/edit/salt-template-56hpdn?file=App.tsx

Are you a JPMorgan Chase & Co. employee?

  • I am an employee of JPMorgan Chase & Co.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions