Boolean Props: Shorthand Syntax
What you'll learn: How to use React's convenient shorthand for passing true boolean values as props.
The Shorthand Pattern
When you want to pass a boolean prop with a value of true, React gives you a convenient shortcut. Instead of writing the full syntax with curly braces and the value, you can simply include the prop name by itself:
<Button enabled />
This is exactly equivalent to:
<Button enabled={true} />
Both expressions pass the prop enabled with a value of true to the Button component.
Why This Exists
This shorthand mirrors HTML's boolean attribute pattern. In HTML, attributes like disabled or checked work the same way—their presence means "true":
<input disabled />
React adopted this familiar convention, making your JSX feel more natural when working with boolean flags.
When to Use It
This shorthand only works for true values. If you need to pass false, you must use the full syntax:
<Button enabled={false} />
You'll commonly see this shorthand with props like:
<Modal open /><Input required /><Feature experimental />
Receiving the Prop
Inside your component, you receive it normally through the props object:
function Button(props) {
console.log(props.enabled); // true
}
Key Takeaway: For boolean props set to true, you can omit ={true} and just write the prop name—it's cleaner and follows familiar HTML conventions.