Skip to content

Optional features tree-shaking #1792

Open
@atomiks

Description

@atomiks

Feature request

Currently, there are optional features that are part of components that add a bunch of bundle size even if not used. trackCursorAxis on Tooltip is one such example.

If we want to add more features to Tooltip like truncation logic, inline() logic, etc, this adds further cost but most users don't need that by default and shouldn't need to incur.

One possible solution is a features prop where you pass in 'features' using imports so bundlers can remove them if they aren't called:

<Tooltip.Root 
  features={[
    Tooltip.trackCursorAxis('both'),
    Tooltip.checkTruncation(),
  ]}
>

Another is component providers:

<Tooltip.TrackCursorAxis value="both">
  <Tooltip.CheckTruncation>
    <Tooltip.Root />
  </Tooltip.CheckTruncation>
</Tooltip.TrackCursorAxis>

This would only apply to non-essential features, as there will still be a baseline of expected behavior and props

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions