Skip to content
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

Change font size #428

Closed
sam-rez opened this issue Dec 9, 2022 · 3 comments
Closed

Change font size #428

sam-rez opened this issue Dec 9, 2022 · 3 comments

Comments

@sam-rez
Copy link

sam-rez commented Dec 9, 2022

Is there a way setting to change font size? I'm on version 4.15.1

@jaywcjlove
Copy link
Member

@sam-rez https://codesandbox.io/embed/react-codemirror-example-codemirror-6-https-github-com-uiwjs-react-codemirror-issues-428-tfoeku?fontsize=14&hidenavigation=1&theme=dark

import React from "react";
import CodeMirror from "@uiw/react-codemirror";
import { EditorView } from "@codemirror/view";
import { javascript } from "@codemirror/lang-javascript";

const fontSize = EditorView.baseTheme({
  "&": {
    backgroundColor: "#fff",
    fontSize: "34px"
  }
});

export default function App() {
  const onChange = React.useCallback((value, viewUpdate) => {
    console.log("value:", value);
  }, []);
  return (
    <div>
      <CodeMirror
        value="console.log('hello world!');"
        height="200px"
        theme="dark"
        extensions={[fontSize, javascript({ jsx: true })]}
        onChange={onChange}
      />
      <CodeMirror
        value="console.log('hello world!');"
        height="200px"
        extensions={[javascript({ jsx: true })]}
        onChange={(value, viewUpdate) => {
          console.log("value:", value);
        }}
      />
    </div>
  );
}

@sam-rez
Copy link
Author

sam-rez commented Dec 9, 2022

Is this recommended over adding CSS class?

@jaywcjlove
Copy link
Member

@sam-rez sam-rez closed this as completed Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants