Search code examples
semantic-ui-react

Checkbox label with URL link in Semantic UI React


Semantic UI React Checkbox can be used like this:

import React from 'react'
import { Checkbox } from 'semantic-ui-react'

const TermsOfServiceCheckbox = () => (
  <Checkbox label='I accept the Terms of Service' />
)

export default TermsOfServiceCheckbox

How do I set the Checkbox label so that the text Terms of Service is a link to a URL?


Solution

  • label prop implements the item shorthand, so you can also pass there:

    <Checkbox label={<label><a href='/'>I accept the Terms of Service</a></label>} />
    <Checkbox label={<label>I accept the <a href='/'>Terms of Service</a></label>} />
    <Checkbox label={{ children: <a href='/'>I accept the Terms of Service</a> }} />