
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
center-console
Advanced tools
jsx for your terminal
this will allow you to layout dynamic console output with an increasingly html complete api as i flesh out features
i wanted a simple way to control some output at work, but couldn't justify spending any real time on it.
yarn add center-console
thanks to babel and it's custom transform for jsx stuff, along with typescript support, we have been able to create a custom 'dom like' and 'react inspired' c-dom. Our render function relies on this 'createElement' function to build the children, and to use the fiber based dom processor.
import ConsoleRender from '..';
import Component from '../component';
const multiLine = `text
and
lines`;
const MultiDiv = ({ children } : {children: any}) : ConsoleDiv => <div alignContent="center" alignSelf='center' height={50}>
{children}
</div>;
class StatefulSplash extends Component {
interval?: NodeJS.Timer
startTime: number
constructor(...props) {
super(...props);
this.state = {
date: 0,
};
this.startTime = Date.now();
this.interval = setInterval(() => {
this.setState({
date: Date.now() - this.startTime,
});
}, 1000);
}
render() {
const { date } = this.state;
const runTime = `running for ${date}ms`;
return <main>
<div alignSelf='top' height={25}>
<span alignContent="left" width={75} color='#2832c2' background='#ffff00'>logo</span>
<span alignContent="right" width={25} background='#ffff00'>{runTime}</span>
</div>
<MultiDiv>{multiLine}</MultiDiv>
<div alignSelf="bottom" height={25}>
<span alignContent="left" width={33}>left</span>
<span alignContent="center" width={33}>right</span>
<span alignContent="right" width={33}>centers</span>
</div>
</main>;
}
}
const someDom = new ConsoleRender();
someDom.display(<StatefulSplash />);
this will output this:
logo running for 1000ms
text
and
lines
left right centers
to use this you gotta update your babel for use with custom jsx like this:
module.exports = {
presets: ['@babel/env', '@babel/typescript'],
plugins: [
[
'@babel/plugin-transform-react-jsx',
{
runtime: 'automatic',
importSource: 'center-console/runtime',
},
],
],
};
and make sure you make ts preserve jsx:
{
"compilerOptions": {
... other options,
"jsx": "preserve",
}
}
there are like 4 props we accept. please use the JSX export this package provides to see what is useable.
as of now you can basically break up the terminal into heights and widths by percent and control vertical/horizontal layouts.
you can add color or background to any element and we will pass the value you supply to the chalk hex function. we support text and background colors.
import
import { CenterConsole } from 'center-console';
const log = new CenterConsole();
log.render(`
hey
`);
there is a type export, refer to it cuz source code rarely gets out of sync with itself, idk about these docs.
c-dom based on a reworking for node of pombo diy react. not a whole hell of a lot of that applied, and it turns out that also having to build a dom sucked.
i like to write dev tools, this can make those tools "sparkle"
open pr, pass lint and commit style, merge
FAQs
a tool to center console output
The npm package center-console receives a total of 7 weekly downloads. As such, center-console popularity was classified as not popular.
We found that center-console demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.