question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem

Looking to be able to set padding through props. Currently have to do editor.renderer.setPadding(value) to set editor padding.

Sample code to reproduce your issue

For example, trying to set padding through style props doesn’t work

import React from 'react';
import { render } from 'react-dom';
import brace from 'brace';
import AceEditor from 'react-ace';

import 'brace/mode/java';
import 'brace/theme/github';

function onChange(newValue) {
  console.log('change',newValue);
}

// Render editor
render(
  <AceEditor
    mode="java"
    theme="github"
    onChange={onChange}
    name="UNIQUE_ID_OF_DIV"
    editorProps={{$blockScrolling: true}}
    style={{padding: 8}}
  />,
  document.getElementById('example')
);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

10reactions
bessarabovcommented, Jun 16, 2019

I’ve been targeting the .ace_content classname in CSS

I’ve tried to use

.ace_content {
    padding: 1rem 0.5rem;
}

This added padding, but it also broke mouse selection. With this css the mouse selection is mispositioned. At last I’ve removed this css and used

<AceEditor
        ...
        onLoad={function(editor){ editor.renderer.setPadding(10); editor.renderer.setScrollMargin(10); }}
        ...

This is not perfect, when you scroll the code in the editor the top “padding” disappears, but for my case it is ok.

1reaction
brandontlecommented, Feb 20, 2019

But for posterity’s sake, the above Codesandbox example only provides side padding, not top or bottom padding.

I’ve been targeting the .ace_content classname in CSS, but if anyone else has a better way for top/bottom padding, would love to hear it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Padding - W3Schools
The padding property is a shorthand property for the following individual padding properties: padding-top; padding-right; padding-bottom; padding-left. So, here ...
Read more >
padding - CSS: Cascading Style Sheets - MDN Web Docs
The padding property may be specified using one, two, three, or four values. Each value is a <length> or a <percentage> .
Read more >
Control.Padding Property (System.Windows.Forms)
A Padding representing the control's internal spacing characteristics. Remarks. For containers such as GroupBox and TabControl, the Padding property gets or ...
Read more >
padding | CSS-Tricks
The padding property in CSS defines the innermost portion of the box model, creating space around an element's content, inside of any ...
Read more >
Spacing - MUI System
The props are named using the format {property}{sides} . Where property is one of: m - for classes that set margin; p -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found