Unable to change focus behavior of `TextInput` / `Selection` components via theme
See original GitHub issueI would like to great a reusable Grommet theme where the focus-state of Selection
and TextInput
is a custom color. There is apparently not possible to change this by providing a theme to a Grommet component. It is not possible by using the Grommet Theme Builder.
Perhaps I am not editing the theme correctly, I don’t know.
Behavior
I provide a theme as a prop to the main app component in index.js
:
const theme = {
"select": {
"background": "black",
"container": {},
"control": {},
"icons": {},
"options": {
"box": {
"align": "start",
"pad": "small"
},
"text": { "margin": "none" }
},
"step": 20,
},
. . . /* more custom theme options */
}
ReactDOM.render(
<Grommet full theme={theme}><App /></Grommet>,
document.getElementById('root')
);
Then in App.js
:
import React from 'react';
import { Select, Box } from 'grommet';
function App() {
return (
<Box>
<DropSelect options={...} placeholder={...} />
</Box>
);
}
function DropSelect(props) {
const [value, setValue] = React.useState(props.placeholder);
return (
<Select
options={props.options}
value={value}
onChange={({ option }) => setValue(option)}
/>
);
}
Unfocused <DropSelect />
:
Focused <DropSelect />
:
I’ve tried providing the theme
object with several variations of attempts to change the outline
and/or border
, as well as attempts to change its style in a focused state. Again, I would like to apply this as a theme to several apps from the highest level possible, without having to do any inline styling.
Any insight would be very helpful.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
Top GitHub Comments
@clockelliptic Just checking in to see if ShimiSun was able to answer your question.
Hi @clockelliptic Have you seen this story where you can customize the theme focus color? https://storybook.grommet.io/?path=/story/theme--focus Does that answer your question?