-
Notifications
You must be signed in to change notification settings - Fork 51
Website - CodeBlock height toggle docs
#2845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
6890f97
6e704e8
24ef892
b782514
82d5e06
a00cb3c
838e7ad
3cc0838
ddfc84d
4803fb8
ff191e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -69,6 +69,21 @@ Line numbers are displayed by default and can make longer blocks of code and sni | |||||
| In the Figma component, the code examples have the appropriate number of lines by default but must be manually hidden or shown to match the length of custom snippets. | ||||||
| !!! | ||||||
|
|
||||||
| ## Height toggle button | ||||||
|
|
||||||
| When displaying longer code snippets, it can be helpful to let users expand and collapse the content to save space in the UI. Setting a `maxHeight` on the Code Block limits how much is shown by default. If the content exceeds this height, a **Show more code** button will be displayed at the bottom of the block, allowing users to expand it. Interacting with the button again collapses the block back to its original height. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Working on tweaking this as it still seems a bit awkward... (I'll make a suggested edit)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andgen404 How's this? (Above suggested edit) |
||||||
|
|
||||||
| In Figma, this is enabled by setting `hasToggleHeightButton` to true. The button is placed inside a footer element that only appears when the content overflows, keeping the layout clean when the toggle isn’t needed. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| Interacting with this button removes the height limit, expanding the Code Block to display the full code snippet. | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| Interacting with it again collapses the Code Block back to its set `maxHeight`. | ||||||
|
|
||||||
|
|
||||||
| ## Line highlighting | ||||||
|
|
||||||
| Use line highlighting to target and call attention to specific lines or multiple lines within a block of code. | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.