Reputation: 1517
I am unable to understand how to align content using the styles parameter in React Semantic UI kit.
I have defined the styles parameter like given below:
var styles = {
navBar: {
backgroundColor: 'dark blue'
},
left: {
textAlign: 'left'
},
rightNav: {
},
verticalLine: {
},
};
Below is part of my code which generates checkboxes along with labels. I need to left align those labels with padding between them and the checkbox.
<Form.Field>
<React.Fragment>
<List horizontal style={styles.left}>
{
womensBoutiqueOptions.map(item => (
<List.Item key={item.key}>
<List.Content>
<List.Header>
{item.text}
</List.Header>
<Checkbox2 name={item.value} checked={this.state.checkedItems.get(item.value)} onChange={this.handleChange} />
</List.Content>
</List.Item>
))
}
</List>
</React.Fragment>
</Form.Field>
Heres the output. The above code uses the semantic UI provided List component. The second list of checkboxes is generated using the ul HTML tag as seen in the screenshot.
Any help will be highly appreciated.
Upvotes: 0
Views: 1383
Reputation: 15821
In Semantic UI checkbox and its label should not be separated by a List.Header:
<List horizontal>
<List.Item>
<Checkbox label='Make my profile visible' />
</List.Item>
<List.Item>
<Checkbox label='Make my profile visible' />
</List.Item>
<List.Item>
<Checkbox label='Make my profile visible' />
</List.Item>
<List.Item>
<Checkbox label='Make my profile visible' />
</List.Item>
<List.Item>
<Checkbox label='Make my profile visible' />
</List.Item>
<List.Item>
<Checkbox label='Make my profile visible' />
</List.Item>
</List>
.ui.checkbox label:before,
.ui.checkbox label:after{
right: 0px;
left: auto;
}
.ui.checkbox label {
padding: 0;
padding-right: 24px;
}
Demo: https://codesandbox.io/s/jlzrplm81w
Upvotes: 1