Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

How to add text label for checkbox #6

Open
vitaliyzolotoy opened this issue Aug 17, 2016 · 10 comments
Open

How to add text label for checkbox #6

vitaliyzolotoy opened this issue Aug 17, 2016 · 10 comments

Comments

@vitaliyzolotoy
Copy link

Hello!

How I can add checkbox__text label to checkbox?

Checkbox({ mods: { size: 'xl' } }, 'Yes, I agree to the')

@deepsweet
Copy link
Member

Hi!

Checkbox itself is a standalone component, so you have to wrap in HTML <label/> the way you like. For example you can use our FieldGroup component:

import FieldGroup from '#field-group';
import Checkbox from '#checkbox';

//
FieldGroup(
    {
        label: 'label text'
        // labelPosition: 'left'
    },
    Checkbox({ checked: true })
);
//

@vitaliyzolotoy
Copy link
Author

And how to add id and for attributes to above blocks?

@vitaliyzolotoy
Copy link
Author

vitaliyzolotoy commented Aug 18, 2016

Label in demo is broken. Can you update demo?

@deepsweet
Copy link
Member

And how to add id and for attributes to above blocks?

There is no need for id and for attrs if you are using <label><input/></label>. But anyway, you can add any attrs with React props:

Checkbox({ checked: true, id: 'my-id' })

Label in demo is broken. Can you update demo?

Oops.

@mistadikay
Copy link
Member

@vitaliyzolotoy there was a misunderstanding — if you want to trigger checkbox by clicking on its label you should wrap it into Label component like in a demo:

import Label from '#label';
import Input from '#input';

// ...
Label({ text: 'click me to trigger checkbox' },
    Input({ type: 'checkbox' })
)
// ...

Label in demo is broken. Can you update demo?

could you please point out on what is broken exactly?

@vitaliyzolotoy
Copy link
Author

vitaliyzolotoy commented Aug 23, 2016

No one of above examples works for me. I just want to add [+] text with clickable label.

@mistadikay
Copy link
Member

@vitaliyzolotoy could you please provide some example of code or a repo — it's really hard to understand what exactly means “nothing works”

@vitaliyzolotoy
Copy link
Author

@mistadikay
Copy link
Member

@vitaliyzolotoy here is the screenshot with a rendered label from demo:
screen shot 2016-09-06 at 10 11 47

If something is not working for you, please provide expected/actual results and steps to reproduce. Also any information about your OS/environment would be helpful. Thanks

@vitaliyzolotoy
Copy link
Author

@mistadikay Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants