| 1 | --- |
| 2 | depends: |
| 3 | - guide/syntax#code-block |
| 4 | tags: [codeblock, layout] |
| 5 | description: | |
| 6 | Set a maximum height for a code block and enable scrolling. |
| 7 | --- |
| 8 | |
| 9 | # Max Height |
| 10 | |
| 11 | If the code doesn't fit into one slide, you use the `maxHeight` to set a fixed height and enable scrolling: |
| 12 | |
| 13 | ````md |
| 14 | ```ts {2|3|7|12}{maxHeight:'100px'} |
| 15 | function add( |
| 16 | a: Ref<number> | number, |
| 17 | b: Ref<number> | number |
| 18 | ) { |
| 19 | return computed(() => unref(a) + unref(b)) |
| 20 | } |
| 21 | /// ...as many lines as you want |
| 22 | const c = add(1, 2) |
| 23 | ``` |
| 24 | ```` |
| 25 | |
| 26 | Note that you can use `{*}` as a placeholder of <LinkInline link="features/line-highlighting" />: |
| 27 | |
| 28 | ````md |
| 29 | ```ts {*}{maxHeight:'100px'} |
| 30 | // ... |
| 31 | ``` |
| 32 | ```` |
| 33 |