How do i make the_posts_pagination look like my template?

function pagination_bar($posts_per_page) {
$published_posts = wp_count_posts()->publish;
$total_pages = ceil($published_posts / $posts_per_page); 
if ($total_pages > 1){
    $current_page = max(1, get_query_var('paged')); 
    echo paginate_links(array(
        'base' => get_pagenum_link(1) . '%_%',
        'format' => '?paged=%#%',
        'current' => $current_page,
        'total' => $total_pages,
    ));
 } }

place the above code in function.php .

<?php pagination_bar($post_details['posts_per_page']); ?>

above function call is where you need to display the pagination.

then using the wp_query get all the posts like examble

<?php           
       if ( get_query_var('paged') ) $paged = get_query_var('paged');
       if ( get_query_var('page') ) $paged = get_query_var('page');
       $post_details = array('post_type'=> 'post','paged'=>$paged,'numberposts' => -1,'posts_per_page' => 2);
       $custom_query = new WP_Query( $post_details );
    ?>