Coder Social home page Coder Social logo

Comments (6)

mperrotti avatar mperrotti commented on May 2, 2024 1

@philernst - I'm not sure we even need a required indicator on that one. I think it would be ok to just return a validation error if it isn't checked.

from brand.

mperrotti avatar mperrotti commented on May 2, 2024

@philernst @rezrah - this is intentional. A single checkbox cannot be required because both checked (true) and unchecked (false) are valid values.

We should update the docs with this information.

from brand.

mperrotti avatar mperrotti commented on May 2, 2024

If you want indicate that a selection must be made in a group of checkboxes, it should be indicated for that whole group of checkboxes. Here's an example from @primer/react: https://primer.style/react/storybook/?path=/story/components-checkboxgroup--playground&args=required:!true

from brand.

philernst avatar philernst commented on May 2, 2024

@mperrotti Got it. The use case I was thinking about is where the submitter is required to check the checkbox to submit the form. For example:

Screenshot 2023-07-21 at 11 06 33 AM

I suppose in that situation a CheckboxGroup would need to be added to indicate that the field is required to be true to submit the form.

from brand.

rezrah avatar rezrah commented on May 2, 2024

A single checkbox cannot be required because both checked (true) and unchecked (false) are valid values.

We should update the docs with this information.

cc. @jesskuo4 - could we add this guidance into your upcoming checkbox interface guidelines please?

from brand.

philernst avatar philernst commented on May 2, 2024

That sounds good to me. The browser validation error does indeed work.

Screenshot 2023-07-21 at 3 07 27 PM

Thank you all!

from brand.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.