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

[Components/Select] Expose access to container props

Open alexluong opened this issue 5 years ago • 5 comments

Is your feature request related to a problem? Please describe.

I'm using the Select components and use them inline. When the component width is small, the position of the arrow down is not appropriate anymore. I'd love to have access to the container div to make changes to the overall layout of the Select component.

Describe the solution you'd like

Have a containerSx prop:

<Select containerSx={{ position: "relative", etc }} />

Describe alternatives you've considered

Currently, to solve this issue I have to create and maintain my own InlineSelect component, which is far from ideal.


PS: Since we're on the topic of Select, I just wonder what if users of theme-ui want to use a different arrow down icon. It seems like there is not a way to change that. Just wonder what you think about it and if you're open to adding some other prop to expose that functionality.

alexluong avatar Feb 23 '20 08:02 alexluong

Thanks for bringing this up! While I'm not entirely sure how this should be implemented, I think the API for this could potentially look something like:

<Select
  sx={{
    // styles for select element
    borderRadius: 5,
    container: {
      // styles for root element
    },
    arrow: {
      // styles for arrow icon go here
    }   
  }}  
/>

jxnblk avatar Mar 03 '20 15:03 jxnblk

Can it be implemented something like this?

const Select(props) {
  <Box sx={{ ...props?.sx?.container }}>
    <Box as="select" {...props} />
    <DownArrow sx={{ ...props?.sx?.arrow }} />
  </Box>
}

See current implementation.

alexluong avatar Mar 04 '20 01:03 alexluong

This is kinda related: https://github.com/system-ui/theme-ui/issues/294

dburles avatar Mar 05 '20 02:03 dburles

Doesn’t fix this issue, but Select now supports custom arrows via #1232

lachlanjc avatar Nov 21 '20 19:11 lachlanjc

how do I include an icon for the option within the select?

SkyBulk avatar May 20 '23 02:05 SkyBulk