gluestack-ui icon indicating copy to clipboard operation
gluestack-ui copied to clipboard

Switch component: Possibility to style handle and track individually

Open federicoportoghese opened this issue 1 year ago • 3 comments

Description

Since the component is directly imported from react native, it doesn't have descendants (such as _track or _thumb) it is impossible to give particular styles to the single elements. It would be nice to have this possibility

Problem Statement

Screenshot 2024-08-22 at 13 55 18

For example: is there a way to add such a particular border or outline around the handle for particular states?

Proposed Solution or API

Is something like this somehow possible?

export function createSwitch<
  SwitchProps,
  HandleProps,
  TrackProps,
>({
  Root,
  Handle,
  Track
}: {
  Root: React.ComponentType<SwitchProps>;
  Handle: React.ComponentType<HandleProps>;
  Track: React.ComponentType<TrackProps>;
}) {
  const Switch = SwitchMain(Root) as any;
  Switch.Handle = SwitchHandle(Handle);
  Switch.Track = SwitchTrack(Track);

  Switch.displayName = 'Switch';
  Switch.Handle.displayName = 'Switch.Handle';
  Switch.Track.displayName = 'Switch.Track';

  return Switch as ISwitchComponentType<
    SwitchProps,
    HandleProps,
    TrackProps,
  >;
}

Alternatives

No response

Additional Information

No response

federicoportoghese avatar Aug 22 '24 12:08 federicoportoghese

hi @federicoportoghese thanks for reporting the issue, We are working on custom switch component which will have all of this options.

rajat693 avatar Aug 28 '24 06:08 rajat693

Thanks for your reply @rajat693. Is there by any chance an estimated date for that to happen? Thanks

federicoportoghese avatar Sep 02 '24 07:09 federicoportoghese

Hi @federicoportoghese , thank you for your patience. We have this on our roadmap and will address it as soon as our core issues are resolved.

rajat693 avatar Sep 03 '24 05:09 rajat693